]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/metaparse/doc/digit_to_int.qbk
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / metaparse / doc / digit_to_int.qbk
1 [#digit_to_int]
2 [section digit_to_int]
3
4 [h1 Synopsis]
5
6 namespace util
7 {
8 template <class D>
9 struct digit_to_int;
10 }
11
12 This is a [link lazy_metafunction lazy template metafunction] that supports
13 [link currying currying].
14
15 [table Arguments
16 [[Name] [Type]]
17 [[`D`] [[link boxed_value boxed] character value]]
18 ]
19
20 [h1 Description]
21
22 Converts a boxed character containing a value in the range `['0'..'9']` to an
23 integer.
24
25 [h1 Return value]
26
27 It returns a [link boxed_value boxed] integer value.
28
29 [h1 Header]
30
31 #include <boost/metaparse/util/digit_to_int.hpp>
32
33 [h1 Expression semantics]
34
35 For any `C` boxed character value in the range `['0'..'9']` the following
36 expressions are equivalent
37
38 digit_to_int<>::apply<C>::type
39 digit_to_int<C>::type
40 digit_to_int_c<C::type::value>::type
41
42 [h1 Example]
43
44 #include <boost/metaparse/util/digit_to_int.hpp>
45
46 #include <type_traits>
47
48 using namespace boost::metaparse;
49
50 struct nullary_metafunction_returning_4
51 {
52 using type = std::integral_constant<char, '4'>;
53 };
54
55 static_assert(
56 util::digit_to_int<std::integral_constant<char, '0'>>::type::value == 0,
57 "it should convert a character to the corresponding integer value"
58 );
59
60 static_assert(
61 util::digit_to_int<>::type
62 ::apply<std::integral_constant<char, '7'>>::type::value == 7,
63 "it should support currying"
64 );
65
66 static_assert(
67 util::digit_to_int<nullary_metafunction_returning_4>::type::value == 4,
68 "it should support lazy evaluation"
69 );
70
71 [endsect]
72