• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1[#int_to_digit_c]
2[section int_to_digit_c]
3
4[h1 Synopsis]
5
6  namespace util
7  {
8    template <int C>
9    struct int_to_digit_c;
10  }
11
12This is a template class similar to a [link metafunction template metafunction]
13but taking an `int` value as argument.
14
15[table Arguments
16  [[Name] [Type]]
17  [[`C`]  [`int` value in the range `[0-9]`]]
18]
19
20[h1 Description]
21
22Converts an integer value in the range `[0-9]` to a character representing that
23decimal value.
24
25[h1 Header]
26
27  #include <boost/metaparse/util/int_to_digit_c.hpp>
28
29[h1 Expression semantics]
30
31The following pairs of expressions are equivalent
32
33  int_to_digit_c<0>::type
34  boost::mpl::char_<'0'>
35
36  int_to_digit<9>::type
37  boost::mpl::char_<'9'>
38
39[h1 Example]
40
41  #include <boost/metaparse/util/int_to_digit_c.hpp>
42
43  using namespace boost::metaparse;
44
45  static_assert(
46    util::int_to_digit_c<0>::type::value == '0',
47    "it should convert an integer value to the corresponding character"
48  );
49
50  static_assert(
51    util::int_to_digit_c<3>::type::value == '3',
52    "it should convert an integer to the corresponding character"
53  );
54
55  static_assert(
56    util::int_to_digit_c<9>::type::value == '9',
57    "it should convert an integer value to the corresponding character"
58  );
59
60[endsect]
61
62