[#foldr_reject_incomplete] [section foldr_reject_incomplete] [h1 Synopsis] template struct foldr_reject_incomplete; This is a [link parser_combinator parser combinator]. [table Arguments [[Name] [Type]] [[`P`] [[link parser parser]]] [[`State`] [[link metaprogramming_value template metaprogramming value]]] [[`BackwardOp`] [[link metafunction_class template metafunction class] taking two arguments]] ] [h1 Description] The same as [link foldr `foldr`], but once `P` rejects the input, `foldr_reject_incomplete` checks if `P` consumes any characters before rejecting the input. If so, `foldr_reject_incomplete` rejects the input with the same error message this last application of `P` returned. Otherwise `foldr_reject_incomplete` accepts the input and gives the same result as [link foldr `foldr`]. Here is a diagram showing how `foldr_reject_incomplete` works by example: using int_token = token; using plus_token = token>; using plus_int = last_of; using sum_op = mpl::lambda>::type; [$images/metaparse/foldr_reject_incomplete_diag1.png [width 70%]] Note that `foldr_reject_incomplete` folds from right to left and therefore does not start folding until it reaches the end of the sequence. Since at the end of the sequence it finds an error, folding does not happen at all. [h1 Header] #include [h1 Expression semantics] For any `p` parser, `t` class, `f` metafunction class taking two arguments, `s` compile-time string and `pos` source position foldr_reject_incomplete::apply is equivalent to first_of, fail_at_first_char_expected

>::apply [h1 Example] #include #include #include #include #include #include #include #include #include #include #include #include using namespace boost::metaparse; using int_token = token; using plus_token = token>; using plus_int = last_of; using sum_op = boost::mpl::lambda>::type; using ints = foldr_reject_incomplete, sum_op>; static_assert( get_result< ints::apply >::type::value == 48, "ints should sum the numbers" ); static_assert( is_error< ints::apply >::type::value, "when the last number is missing, it should be an error" ); [endsect]