Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

int_to_digit

Synopsis

namespace util
{
  template <class D>
  struct int_to_digit;
}

This is a lazy template metafunction that supports currying.

Table 43. Arguments

Name

Type

D

boxed integer value


Description

Converts a boxed integer value in the range [0-9] to a character representing that decimal value.

Header

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

Expression semantics

The following pairs of expressions are equivalent

int_to_digit<boost::mpl::int_<0>>::type
boost::mpl::char_<'0'>

int_to_digit<boost::mpl::int_<9>>::type
boost::mpl::char_<'9'>

Example

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

#include <type_traits>

using namespace boost::metaparse;

struct nullary_metafunction_returning_4
{
  using type = std::integral_constant<int, 4>;
};

static_assert(
  util::int_to_digit<std::integral_constant<int, 0>>::type::value == '0',
  "it should convert an integer value to the corresponding character"
);

static_assert(
  util::int_to_digit<>::type
    ::apply<std::integral_constant<int, 7>>::type::value == '7',
  "it should support currying"
);

static_assert(
  util::int_to_digit<nullary_metafunction_returning_4>::type::value == '4',
  "it should support lazy evaluation"
);

PrevUpHomeNext