string.qbk 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. [#string]
  2. [section string]
  3. [h1 Synopsis]
  4. template <char C1, ..., char Cn>
  5. struct string;
  6. This is a [link metaprogramming_value template metaprogramming value].
  7. [table Arguments
  8. [[Name] [Type]]
  9. [[`C1`..`Cn`] [character values]]
  10. ]
  11. [h1 Description]
  12. Compile-time data-structure describing a string object. These string objects are
  13. compatible with `boost::mpl::string`, but they accept only individual characters
  14. as arguments. When `constexpr` is available, they can be constructed using the
  15. [link BOOST_METAPARSE_STRING `BOOST_METAPARSE_STRING`] macro.
  16. The tag of the strings is [link string_tag `string_tag`].
  17. [*C++98]: The maximum length of these strings is controlled by the
  18. `BOOST_METAPARSE_LIMIT_STRING_SIZE` macro.
  19. [*C++11]: The strings use variadic templates.
  20. [h1 Header]
  21. #include <boost/metaparse/string.hpp>
  22. [h1 Example]
  23. #include <boost/metaparse/string.hpp>
  24. #include <type_traits>
  25. using namespace boost::metaparse;
  26. using hello1 = string<'H','e','l','l','o'>;
  27. using hello2 = BOOST_METAPARSE_STRING("Hello");
  28. static_assert(
  29. std::is_same<
  30. string<'H', 'e', 'l', 'l', 'o'>,
  31. BOOST_METAPARSE_STRING("Hello")
  32. >::type::value,
  33. "The type generated by the macro should be identical to the hand-crafted one."
  34. );
  35. [endsect]