1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- [#in_range_c]
- [section in_range_c]
- [h1 Synopsis]
- namespace util
- {
- template <class T, T LowerBound, T UpperBound>
- struct in_range_c
- {
- template <class U>
- struct apply;
- };
- }
- This is a [link metafunction_class template metafunction class].
- [table Arguments
- [[Name] [Type]]
- [[`T`] [integral type]]
- [[`LowerBound`] [value of type `T`]]
- [[`UpperBound`] [value of type `T`]]
- [[`U`] [[link boxed_value boxed integral value]]]
- ]
- [h1 Description]
- Metafunction class verifying that `U` is in the `[LowerBound..UpperBound]` range
- or not.
- [h1 Header]
- #include <boost/metaparse/util/in_range_c.hpp>
- [h1 Expression semantics]
- For any `T` integral type, `A`, `B` values of type `T` and `C` wrapped value the
- following are equivalent:
- in_range_c<T, A, B>::apply<C>::type::value
-
- A <= C::type::value && C::type::value <= B
- [h1 Example]
- #include <boost/metaparse/util/in_range_c.hpp>
-
- #include <type_traits>
-
- using namespace boost::metaparse;
-
- static_assert(
- !util::in_range_c<int, 11, 13>
- ::apply<std::integral_constant<int, 10>>::type::value,
- "A value below the lower bound should not be in the range"
- );
-
- static_assert(
- !util::in_range_c<int, 11, 13>
- ::apply<std::integral_constant<int, 14>>::type::value,
- "A value above the upper bound should not be in the range"
- );
-
- static_assert(
- util::in_range_c<int, 11, 13>
- ::apply<std::integral_constant<int, 11>>::type::value,
- "The lower bound should be in the range"
- );
-
- static_assert(
- util::in_range_c<int, 11, 13>
- ::apply<std::integral_constant<int, 13>>::type::value,
- "The upper bound should be in the range"
- );
-
- static_assert(
- util::in_range_c<int, 11, 13>
- ::apply<std::integral_constant<int, 12>>::type::value,
- "A value between the bounds should be in the range"
- );
- [endsect]
|