]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/metaparse/doc/BOOST_METAPARSE_STRING.qbk
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / metaparse / doc / BOOST_METAPARSE_STRING.qbk
1 [#BOOST_METAPARSE_STRING]
2 [section BOOST_METAPARSE_STRING]
3
4 [h1 Synopsis]
5
6 #define BOOST_METAPARSE_STRING(s) \
7 // unspecified
8
9 This is a macro.
10
11 [table Arguments
12 [[Name] [Type]]
13 [[`s`] [string literal]]
14 ]
15
16 [h1 Description]
17
18 Macro for defining [link string `string`] values. `s` is expected to be a
19 string literal. The macro requires C++11.
20
21 The maximal length of the string is limited. This limit is defined by the
22 `BOOST_METAPARSE_LIMIT_STRING_SIZE` macro.
23
24 On platforms where `BOOST_METAPARSE_STRING` is not supported, the `string.hpp`
25 header defines the `BOOST_METAPARSE_V1_CONFIG_NO_BOOST_METAPARSE_STRING` macro.
26 Defining this macro before including the header disables the
27 `BOOST_METAPARSE_STRING` macro.
28
29 The upper limit for the maximum length, which can be used is 2048. The
30 implementation of the `BOOST_METAPARSE_STRING` macro is generated using
31 `tools/string_headers.py` and can be regenerated to extend this upper limit.
32 Note that for Oracle Developer Studio the string length limit is 127.
33
34 Metaparse supports changing the string length limit within a compilation unit.
35 To change the length limit, redefine the `BOOST_METAPARSE_LIMIT_STRING_SIZE`
36 macro.
37
38 You can find benchmarks of this macro
39 [link BOOST_METAPARSE_STRING_benchmark here].
40
41 [h1 Header]
42
43 #include <boost/metaparse/string.hpp>
44
45 [h1 Expression semantics]
46
47 The semantics of this macro is demonstrated by an example. The following
48
49 BOOST_METAPARSE_STRING("hello")
50
51 is equivalent to
52
53 string<'h','e','l','l','o'>
54
55 [h1 Example]
56
57 #define BOOST_METAPARSE_LIMIT_STRING_SIZE 8
58 #include <boost/metaparse/string.hpp>
59
60 #include <type_traits>
61
62 using namespace boost::metaparse;
63
64 using hello1 = string<'H','e','l','l','o'>;
65 using hello2 = BOOST_METAPARSE_STRING("Hello");
66
67 static_assert(
68 std::is_same<
69 string<'H', 'e', 'l', 'l', 'o'>,
70 BOOST_METAPARSE_STRING("Hello")
71 >::type::value,
72 "The type generated by the macro should be identical to the hand-crafted one."
73 );
74
75 #undef BOOST_METAPARSE_LIMIT_STRING_SIZE
76 #define BOOST_METAPARSE_LIMIT_STRING_SIZE 32
77
78 static_assert(
79 std::is_same<
80 string<
81 'A', ' ', 'l', 'o', 'n', 'g', 'e', 'r',
82 ' ', 's', 't', 'r', 'i', 'n', 'g'
83 >,
84 BOOST_METAPARSE_STRING("A longer string")
85 >::type::value,
86 "The type generated by the macro should be identical to the hand-crafted one."
87 );
88
89 [endsect]
90