int_to_digit_c.qbk 1.2 KB

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