1
0
Fork 0
arangodb/3rdParty/boost/1.62.0/libs/metaparse/doc/one_of_c.qbk

64 lines
1.4 KiB
Plaintext

[#one_of_c]
[section one_of_c]
[h1 Synopsis]
template <long P1, long P2, /* ... */ long Pn>
struct one_of_c;
This is a [link parser parser].
[table Arguments
[[Name] [Type]]
[[`P1` .. `Pn`] [character values]]
]
[h1 Description]
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`.
[h1 Header]
#include <boost/metaparse/one_of_c.hpp>
[h1 Expression semantics]
For any `c1`, ..., `cn` characters
one_of_c<c1, ..., cn>
is equivalent to
one_of<lit_c<c1>, /* ... */, lit_c<cn>>
[h1 Example]
#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"
);
[endsect]