Home | Libraries | People | FAQ | More |
template <long P1, long P2, /* ... */ long Pn> struct one_of_c;
This is a parser.
It accepts inputs beginning with any of the P1
,
..., Pn
characters. The
result of parsing is the first character of the input.
The maximum number of characters that can be provided is defined by the
BOOST_METAPARSE_LIMIT_ONE_OF_SIZE
macro. Its default value is 20
.
#include <boost/metaparse/one_of_c.hpp>
For any c1
, ..., cn
characters
one_of_c<c1, ..., cn>
is equivalent to
one_of<lit_c<c1>, /* ... */, lit_c<cn>>
#include <boost/metaparse/one_of_c.hpp> #include <boost/metaparse/start.hpp> #include <boost/metaparse/string.hpp> #include <boost/metaparse/get_result.hpp> #include <boost/metaparse/is_error.hpp> using namespace boost::metaparse; using whitespace = one_of_c<' ', '\n', '\r', '\t', '\v'>; static_assert( get_result< whitespace::apply<BOOST_METAPARSE_STRING(" "), start> >::type::value == ' ', "the result of parsing should be the first character of the input" ); static_assert( is_error<whitespace::apply<BOOST_METAPARSE_STRING("x"), start>>::type::value, "it should return an error when the input does not begin with a whitespace" );