]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/metaparse/doc/in_range.qbk
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / metaparse / doc / in_range.qbk
1 [#in_range]
2 [section in_range]
3
4 [h1 Synopsis]
5
6 namespace util
7 {
8 template <class LowerBound, class UpperBound, class Item>
9 struct in_range;
10 }
11
12 This is a [link metafunction template metafunction] supporting
13 [link currying currying].
14
15 [table Arguments
16 [[Name] [Type]]
17 [[`LowerBound`] [[link boxed_value boxed integral value]]]
18 [[`UpperBound`] [[link boxed_value boxed integral value]]]
19 [[`Item`] [[link boxed_value boxed integral value]]]
20 ]
21
22 [h1 Description]
23
24 It returns a boxed boolean value. The value is `true` when `Item` is in the
25 range `[LowerBound..UpperBound]` and `false` otherwise. `boost::mpl::less_equal`
26 is used for comparison.
27
28 [h1 Header]
29
30 #include <boost/metaparse/util/in_range.hpp>
31
32 [h1 Expression semantics]
33
34 For any `L`, `U` and `T` classes the following are equivalent:
35
36 in_range<L, U>::apply<T>::type::value
37
38 boost::mpl::less_equal<L, T>::type::value
39 && boost::mpl::less_equal<T, U>::type::value
40
41 [h1 Example]
42
43 #include <boost/metaparse/util/in_range.hpp>
44
45 #include <boost/mpl/int.hpp>
46
47 using namespace boost::metaparse;
48
49 static_assert(
50 !util::in_range<
51 boost::mpl::int_<11>,
52 boost::mpl::int_<13>,
53 boost::mpl::int_<10>
54 >::type::value,
55 "A value below the lower bound should not be in the range"
56 );
57
58 static_assert(
59 !util::in_range<
60 boost::mpl::int_<11>,
61 boost::mpl::int_<13>,
62 boost::mpl::int_<14>
63 >::type::value,
64 "A value above the upper bound should not be in the range"
65 );
66
67 static_assert(
68 util::in_range<
69 boost::mpl::int_<11>,
70 boost::mpl::int_<13>,
71 boost::mpl::int_<11>
72 >::type::value,
73 "The lower bound should be in the range"
74 );
75
76 static_assert(
77 util::in_range<
78 boost::mpl::int_<11>,
79 boost::mpl::int_<13>,
80 boost::mpl::int_<13>
81 >::type::value,
82 "The upper bound should be in the range"
83 );
84
85 static_assert(
86 util::in_range<
87 boost::mpl::int_<11>,
88 boost::mpl::int_<13>,
89 boost::mpl::int_<12>
90 >::type::value,
91 "A value between the bounds should be in the range"
92 );
93
94 static_assert(
95 util::in_range<>
96 ::apply<boost::mpl::int_<11>>::type
97 ::apply<boost::mpl::int_<13>>::type
98 ::apply<boost::mpl::int_<12>>::type
99 ::type::value,
100 "It should support currying"
101 );
102
103 [endsect]
104