Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

BOOST_METAPARSE_STRING

Synopsis

#define BOOST_METAPARSE_STRING(s) \
  // unspecified

This is a macro.

Table 7. Arguments

Name

Type

s

string literal


Description

Macro for defining string values. s is expected to be a string literal. The macro requires C++11.

The maximal length of the string is limited. This limit is defined by the BOOST_METAPARSE_LIMIT_STRING_SIZE macro.

On platforms where BOOST_METAPARSE_STRING is not supported, the string.hpp header defines the BOOST_METAPARSE_V1_CONFIG_NO_BOOST_METAPARSE_STRING macro. Defining this macro before including the header disables the BOOST_METAPARSE_STRING macro.

Header

#include <boost/metaparse/string.hpp>

Expression semantics

The semantics of this macro is demonstrated by an example. The following

BOOST_METAPARSE_STRING("hello")

is equivalent to

string<'h','e','l','l','o'>

Example

#include <boost/metaparse/string.hpp>

#include <type_traits>

using namespace boost::metaparse;

using hello1 = string<'H','e','l','l','o'>;
using hello2 = BOOST_METAPARSE_STRING("Hello");

static_assert(
  std::is_same<
    string<'H', 'e', 'l', 'l', 'o'>,
    BOOST_METAPARSE_STRING("Hello")
  >::type::value,
  "The type generated by the macro should be identical to the hand-crafted one."
);

PrevUpHomeNext