Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

in_range_c

Synopsis

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

T

integral type

LowerBound

value of type T

UpperBound

value of type T

U

boxed integral value


Description

Metafunction class verifying that U is in the [LowerBound..UpperBound] range or not.

Header

#include <boost/metaparse/util/in_range_c.hpp>

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

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"
);

PrevUpHomeNext