6 template <class P, int N>
9 This is a [link parser_combinator parser combinator].
13 [[`P`] [[link parser parser]]]
14 [[`N`] [non-negative integer value]]
19 It applies `P` on the input string `N` times. The result of parsing is a
20 sequence of the results of the individual applications of `P`. `P` has to accept
21 the input `N` times for `iterate_c` to accept it.
25 #include <boost/metaparse/iterate_c.hpp>
27 [h1 Expression semantics]
29 For any `p` parser, `n` integer value the following are equivalent:
42 #include <boost/metaparse/iterate_c.hpp>
43 #include <boost/metaparse/digit.hpp>
44 #include <boost/metaparse/string.hpp>
45 #include <boost/metaparse/start.hpp>
46 #include <boost/metaparse/get_result.hpp>
47 #include <boost/metaparse/is_error.hpp>
49 #include <boost/mpl/vector.hpp>
50 #include <boost/mpl/equal.hpp>
51 #include <boost/mpl/char.hpp>
53 using namespace boost::metaparse;
58 boost::mpl::char_<'1'>,
59 boost::mpl::char_<'2'>,
60 boost::mpl::char_<'3'>
63 iterate_c<digit, 3>::apply<BOOST_METAPARSE_STRING("123"), start>
66 "the result should be the sequence of the individual applications of digit"
72 boost::mpl::char_<'1'>,
73 boost::mpl::char_<'2'>,
74 boost::mpl::char_<'3'>
77 iterate_c<digit, 3>::apply<BOOST_METAPARSE_STRING("1234"), start>
80 "only three iterations should be made"
85 iterate_c<digit, 3>::apply<BOOST_METAPARSE_STRING("12"), start>
87 "it should fail when digit can not be applied three times"