metaparse/doc/int_to_digit.qbk
2015-07-19 09:53:35 +02:00

70 lines
1.4 KiB
Plaintext

[#int_to_digit]
[section int_to_digit]
[h1 Synopsis]
namespace util
{
template <class D>
struct int_to_digit;
}
This is a [link lazy_metafunction lazy template metafunction] that supports
[link currying currying].
[table Arguments
[[Name] [Type]]
[[`D`] [[link boxed_value boxed] integer value]]
]
[h1 Description]
Converts a boxed integer value in the range `[0-9]` to a character representing
that decimal value.
[h1 Header]
#include <boost/metaparse/util/int_to_digit.hpp>
[h1 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'>
[h1 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"
);
[endsect]