12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- [#digit_to_int_c]
- [section digit_to_int_c]
- [h1 Synopsis]
- namespace util
- {
- template <char D>
- struct digit_to_int_c;
- }
- This is a template class similar to a [link metafunction template metafunction]
- but taking a `char` value as argument.
- [table Arguments
- [[Name] [Type]]
- [[`D`] [character value]]
- ]
- [h1 Description]
- Converts a character containing a value in the range `['0'..'9']` to an integer.
- [h1 Return value]
- It returns a [link boxed_value boxed] integer value.
- [h1 Header]
- #include <boost/metaparse/util/digit_to_int_c.hpp>
- [h1 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>
- [h1 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"
- );
- [endsect]
|