Home | Libraries | People | FAQ | More |
namespace util { template <class T, T LowerBound, T UpperBound> struct in_range_c { template <class U> struct apply; }; }
This is a template metafunction class.
Table 40. Arguments
Name |
Type |
---|---|
|
integral type |
|
value of type |
|
value of type |
|
Metafunction class verifying that U
is in the [LowerBound..UpperBound]
range or not.
#include <boost/metaparse/util/in_range_c.hpp>
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
#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" );