Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

digit_to_int_c

Synopsis

namespace util
{
  template <char D>
  struct digit_to_int_c;
}

This is a template class similar to a template metafunction but taking a char value as argument.

Table 12. Arguments

Name

Type

D

character value


Description

Converts a character containing a value in the range ['0'..'9'] to an integer.

Return value

It returns a boxed integer value.

Header

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

Expression semantics

The following pairs of expressions are equivalent

digit_to_int_c<'0'>::type
boost::mpl::int_<0>

digit_to_int_c<'9'>::type
boost::mpl::int_<9>

Example

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

using namespace boost::metaparse;

static_assert(
  util::digit_to_int_c<'0'>::type::value == 0,
  "it should convert a character to the corresponding integer value"
);

static_assert(
  util::digit_to_int_c<'3'>::type::value == 3,
  "it should convert a character to the corresponding integer value"
);

static_assert(
  util::digit_to_int_c<'9'>::type::value == 9,
  "it should convert a character to the corresponding integer value"
);

PrevUpHomeNext