[#first_of]
[section first_of]

[h1 Synopsis]

  template <class P1, /* ... */, class Pn>
  struct first_of;

This is a [link parser_combinator parser combinator].

[table Arguments
  [[Name]         [Type]]
  [[`P1` .. `Pn`] [[link parser parser]]]
]

[h1 Description]

`first_of` applies the `P1` ... `Pn` parsers in sequence. It accepts an input
when all parsers accept it. The result of parsing is the result of the first
parser.

[h1 Header]

  #include <boost/metaparse/first_of.hpp>

[h1 Expression semantics]

For any `p1`, ... `pn` parsers

  first_of<p1, ..., pn>

is equivalent to

  nth_of_c<0, p1, ..., pn>

[h1 Example]

  #include <boost/metaparse/first_of.hpp>
  #include <boost/metaparse/int_.hpp>
  #include <boost/metaparse/lit_c.hpp>
  #include <boost/metaparse/string.hpp>
  #include <boost/metaparse/start.hpp>
  #include <boost/metaparse/is_error.hpp>
  #include <boost/metaparse/get_result.hpp>
  
  #include <type_traits>
  
  using namespace boost::metaparse;
  
  using int_with_semicolon = first_of<int_, lit_c<';'>>;
  
  static_assert(
    is_error<
      int_with_semicolon::apply<BOOST_METAPARSE_STRING("13"), start>
    >::type::value,
    "int without semicolon is rejected"
  );
  
  static_assert(
    get_result<
      int_with_semicolon::apply<BOOST_METAPARSE_STRING("13;"), start>
    >::type::value,
    "the result is the result of the first parser"
  );

[endsect]

