]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/metaparse/doc/lit_c.qbk
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / metaparse / doc / lit_c.qbk
1 [#lit_c]
2 [section lit_c]
3
4 [h1 Synopsis]
5
6 template <char C>
7 struct lit;
8
9 This is a [link parser parser].
10
11 [table Arguments
12 [[Name] [Type]]
13 [[`C`] [`char` value]]
14 ]
15
16 [h1 Description]
17
18 Parser accepting only the `C` character. The result of parsing is the accepted
19 character.
20
21 [h1 Header]
22
23 #include <boost/metaparse/lit_c.hpp>
24
25 [h1 Expression semantics]
26
27 For any `c` character the following are equivalent:
28
29 lit_c<c>
30
31 lit<boost::mpl::char_<c>>
32
33 [h1 Example]
34
35 #include <boost/metaparse/lit_c.hpp>
36 #include <boost/metaparse/start.hpp>
37 #include <boost/metaparse/string.hpp>
38 #include <boost/metaparse/is_error.hpp>
39 #include <boost/metaparse/get_result.hpp>
40
41 using namespace boost::metaparse;
42
43 static_assert(
44 is_error<lit_c<'x'>::apply<BOOST_METAPARSE_STRING("a"), start>>::type::value,
45 "a different character should be an error"
46 );
47
48 static_assert(
49 is_error<lit_c<'x'>::apply<BOOST_METAPARSE_STRING(""), start>>::type::value,
50 "empty input should be an error"
51 );
52
53 static_assert(
54 get_result<
55 lit_c<'x'>::apply<BOOST_METAPARSE_STRING("x"), start>
56 >::type::value == 'x',
57 "result of parsing should be the accepted character"
58 );
59
60 [endsect]
61