1 #ifndef BOOST_METAPARSE_V1_FOLDL_REJECT_INCOMPLETE_HPP
2 #define BOOST_METAPARSE_V1_FOLDL_REJECT_INCOMPLETE_HPP
4 // Copyright Abel Sinkovics (abel@sinkovics.hu) 2015.
5 // Distributed under the Boost Software License, Version 1.0.
6 // (See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
9 #include <boost/metaparse/v1/fail_at_first_char_expected.hpp>
10 #include <boost/metaparse/v1/is_error.hpp>
11 #include <boost/metaparse/v1/get_position.hpp>
12 #include <boost/metaparse/v1/get_result.hpp>
13 #include <boost/metaparse/v1/get_remaining.hpp>
15 #include <boost/mpl/eval_if.hpp>
16 #include <boost/mpl/equal_to.hpp>
24 template <class P, class State, class ForwardOp>
25 struct foldl_reject_incomplete
29 struct apply_unchecked :
30 // I need to use apply_wrap, and not apply, because apply would
31 // build a metafunction class from foldl<P, State, ForwardOp>
32 // when ForwardOp is a lambda expression.
33 foldl_reject_incomplete<
35 typename ForwardOp::template apply<
37 typename get_result<Res>::type
41 typename get_remaining<Res>::type,
42 typename get_position<Res>::type
46 template <class S, class Pos>
47 struct accept_state : accept<typename State::type, S, Pos> {};
49 template <class S, class Pos>
50 struct end_of_folding :
52 typename boost::mpl::equal_to<
54 typename get_position<typename P::template apply<S, Pos> >::type
57 typename P::template apply<S, Pos>
61 typedef foldl_reject_incomplete type;
63 template <class S, class Pos>
66 typename is_error<typename P::template apply<S, Pos> >::type,
67 end_of_folding<S, Pos>,
68 apply_unchecked<typename P::template apply<S, Pos> >