]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/metaparse/doc/range.qbk
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / metaparse / doc / range.qbk
CommitLineData
7c673cae
FG
1[#range]
2[section range]
3
4[h1 Synopsis]
5
6 template <class From, class To>
7 struct range;
8
9This is a [link parser parser].
10
11[table Arguments
12 [[Name] [Type]]
13 [[`From`] [[link boxed_value boxed] character value]]
14 [[`To`] [[link boxed_value boxed] character value]]
15]
16
17[h1 Description]
18
19`range` accepts one character in the range `[From..To]`. The result of the
20parser is the accepted character.
21
22[h1 Header]
23
24 #include <boost/metaparse/range.hpp>
25
26[h1 Expression semantics]
27
28For any `A`, `B` wrapped characters the following are equivalent:
29
30 range<A, B>
31
32 accept_when<one_char, util::in_range<A, B>, errors::unexpected_character>
33
34[h1 Example]
35
36 #include <boost/metaparse/range.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 one_digit =
47 range<std::integral_constant<char, '0'>, std::integral_constant<char, '9'>>;
48
49 static_assert(
50 !is_error<one_digit::apply<BOOST_METAPARSE_STRING("0"), start>>::type::value,
51 "one_digit should accept a digit"
52 );
53
54 static_assert(
55 is_error<one_digit::apply<BOOST_METAPARSE_STRING("x"), start>>::type::value,
56 "one_digit should reject a value outside of ['0'..'9']"
57 );
58
59 static_assert(
60 get_result<
61 one_digit::apply<BOOST_METAPARSE_STRING("0"), start>
62 >::type::value == '0',
63 "the result of parsing should be the character value"
64 );
65
66[endsect]
67