6 template <class From, class To>
9 This is a [link parser parser].
13 [[`From`] [[link boxed_value boxed] character value]]
14 [[`To`] [[link boxed_value boxed] character value]]
19 `range` accepts one character in the range `[From..To]`. The result of the
20 parser is the accepted character.
24 #include <boost/metaparse/range.hpp>
26 [h1 Expression semantics]
28 For any `A`, `B` wrapped characters the following are equivalent:
32 accept_when<one_char, util::in_range<A, B>, errors::unexpected_character>
36 #include <boost/metaparse/range.hpp>
37 #include <boost/metaparse/start.hpp>
38 #include <boost/metaparse/string.hpp>
39 #include <boost/metaparse/is_error.hpp>
40 #include <boost/metaparse/get_result.hpp>
42 #include <type_traits>
44 using namespace boost::metaparse;
47 range<std::integral_constant<char, '0'>, std::integral_constant<char, '9'>>;
50 !is_error<one_digit::apply<BOOST_METAPARSE_STRING("0"), start>>::type::value,
51 "one_digit should accept a digit"
55 is_error<one_digit::apply<BOOST_METAPARSE_STRING("x"), start>>::type::value,
56 "one_digit should reject a value outside of ['0'..'9']"
61 one_digit::apply<BOOST_METAPARSE_STRING("0"), start>
62 >::type::value == '0',
63 "the result of parsing should be the character value"