6 template <int N, class P0, /* ... */, class Pk>
9 This is a [link parser_combinator parser combinator].
13 [[`N`] [`int` value in the range `[0..k]`]]
14 [[`P0`..`Pk`] [[link parser parser]s]]
19 `nth_of_c` applies the `P0` .. `Pk` parsers in sequence. It accepts an input
20 when all of these parsers accept it. The result of parsing is the result of the
23 The maximum number of parsers `nth_of_c` accepts can be specified with the
24 `BOOST_METAPARSE_LIMIT_SEQUENCE_SIZE` macro. Its default value is `5`.
28 #include <boost/metaparse/nth_of.hpp>
30 [h1 Expression semantics]
31 For any `p0`, ..., `pn` parsers and `k` integer value, where `0 <= k < n` the
32 following are equivalent
34 nth_of_c<k, p0, ..., pn>
36 transform<sequence<p0, ..., pn>, boost::mpl::at_c<boost::mpl::_1, k>>
40 #include <boost/metaparse/nth_of_c.hpp>
41 #include <boost/metaparse/int_.hpp>
42 #include <boost/metaparse/lit_c.hpp>
43 #include <boost/metaparse/token.hpp>
44 #include <boost/metaparse/start.hpp>
45 #include <boost/metaparse/string.hpp>
46 #include <boost/metaparse/is_error.hpp>
47 #include <boost/metaparse/get_result.hpp>
49 using namespace boost::metaparse;
51 using int_token = token<int_>;
52 using left_paren_token = token<lit_c<'('>>;
53 using right_paren_token = token<lit_c<')'>>;
56 nth_of_c<1, left_paren_token, int_token, right_paren_token>;
60 int_in_parens::apply<BOOST_METAPARSE_STRING("(13)"), start>
62 "it should return the result of the second parser"
67 int_in_parens::apply<BOOST_METAPARSE_STRING("13"), start>
69 "it should reject the input when there are no parens"
74 int_in_parens::apply<BOOST_METAPARSE_STRING("(13"), start>
76 "it should reject the input when there is no closing paren"