Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

is_digit

Synopsis

namespace util
{
  template <class C>
  struct is_digit;
}

This is a lazy template metafunction that supports currying.

Table 44. Arguments

Name

Type

C

boxed character value


Description

Checks if C is a digit value or not. Returns a boxed boolean value.

Header

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

Expression semantics

The following expressions are equivalent:

is_digit<boost::mpl::char_<'0'>>::type
is_digit<>::apply<boost::mpl::char_<'0'>>::type
boost::mpl::true_

The following expressions are also equivalent:

is_digit<>::apply<c>::type
boost::mpl::false_

Example

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

#include <type_traits>

using namespace boost::metaparse;

struct returns_char
{
  using type = std::integral_constant<char, '0'>;
};

static_assert(
  util::is_digit<std::integral_constant<char, '0'>>::type::value,
  "digit character should be a digit"
);

static_assert(
  !util::is_digit<std::integral_constant<char, 'x'>>::type::value,
  "letter should not be a digit"
);

static_assert(
  util::is_digit<>::type::apply<std::integral_constant<char, '0'>>::type::value,
  "it should support currying"
);

static_assert(
  util::is_digit<returns_char>::type::value,
  "it should support lazy evaluation"
);

PrevUpHomeNext