]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/metaparse/doc/always_c.qbk
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / metaparse / doc / always_c.qbk
CommitLineData
7c673cae
FG
1[#always_c]
2[section always_c]
3
4[h1 Synopsis]
5
6 template <char C, class T>
7 struct always_c;
8
9This is a [link parser_combinator parser combinator].
10
11[table Arguments
12 [[Name] [Type]]
13 [[`C`] [character]]
14 [[`T`] [[link metaprogramming_value template metaprogramming value]]]
15]
16
17[h1 Description]
18
19It accepts inputs beginning with the `C` character. It consumes that character
20and the result of parsing is `T`. Other inputs as rejected.
21
22[h1 Header]
23
24 #include <boost/metaparse/always_c.hpp>
25
26[h1 Expression semantics]
27
28For any `c` character and `t` class the following are equivalent:
29
30 always_c<c, t>
31
32 always<lit_c<c>, t>
33
34[h1 Example]
35
36 #include <boost/metaparse/always_c.hpp>
37 #include <boost/metaparse/start.hpp>
38 #include <boost/metaparse/string.hpp>
39 #include <boost/metaparse/is_error.hpp>
40 #include <boost/metaparse/get_result.hpp>
41
42 #include <type_traits>
43
44 using namespace boost::metaparse;
45
46 using always13 = always_c<'x', std::integral_constant<int, 13>>;
47
48 static_assert(
49 !is_error<always13::apply<BOOST_METAPARSE_STRING("x"), start>>::type::value,
50 "always13 should accept x"
51 );
52
53 static_assert(
54 std::is_same<
55 get_result<always13::apply<BOOST_METAPARSE_STRING("x"), start>>::type,
56 std::integral_constant<int, 13>
57 >::type::value,
58 "the result of parsing should be the integral_constant type"
59 );
60
61 static_assert(
62 is_error<always13::apply<BOOST_METAPARSE_STRING("y"), start>>::type::value,
63 "always13 should reject characters other than x"
64 );
65
66[endsect]
67