[#one_of] [section one_of] [h1 Synopsis] template struct one_of; This is a [link parser_combinator parser combinator]. [table Arguments [[Name] [Type]] [[`Ps`] [[link parser parser]s]] ] [h1 Description] It accepts an input when any of the `Ps...` parsers accept it. The result of parsing is the result of applying the first parser that accepts the input. The parsers are tried in order, therefore in case of ambiguous grammars the result of parsing depends on the order of the `Ps...` parsers. On compilers, which are not C++11-compliant, the maximum number of accepted parsers is defined by the `BOOST_METAPARSE_LIMIT_ONE_OF_SIZE` macro. Its default value is `20`. [h1 Header] #include [h1 Expression semantics] For any `p1`, ..., `pn` parsers, `s` compile-time string and `pos` source position one_of::apply is equivalent to pk::apply when there is a `k`, that `pi::apply::type` returns an error for every `i` in the range `[1..k)` and `pk::apply::type` doesn't return an error. The parser combinator returns an error when there is no such `k`. [h1 Example] #include #include #include #include #include #include using namespace boost::metaparse; using whitespace = one_of, lit_c<'\n'>, lit_c<'\r'>, lit_c<'\t'>, lit_c<'\v'>>; static_assert( get_result< whitespace::apply >::type::value == ' ', "the result of parsing should be the first character of the input" ); static_assert( is_error>::type::value, "it should return an error when the input does not begin with a whitespace" ); [endsect]