]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/metaparse/v1/foldl.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / metaparse / v1 / foldl.hpp
1 #ifndef BOOST_METAPARSE_V1_FOLDL_HPP
2 #define BOOST_METAPARSE_V1_FOLDL_HPP
3
4 // Copyright Abel Sinkovics (abel@sinkovics.hu) 2011.
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)
8
9 #include <boost/metaparse/v1/accept.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>
14
15 #include <boost/mpl/eval_if.hpp>
16
17 namespace boost
18 {
19 namespace metaparse
20 {
21 namespace v1
22 {
23 template <class P, class State, class ForwardOp>
24 struct foldl
25 {
26 private:
27 template <class Res>
28 struct apply_unchecked :
29 // foldl never returns error
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<
34 P,
35 typename ForwardOp::template apply<
36 typename State::type,
37 typename get_result<Res>::type
38 >,
39 ForwardOp
40 >::template apply<
41 typename get_remaining<Res>::type,
42 typename get_position<Res>::type
43 >
44 {};
45
46 template <class S, class Pos>
47 struct next_iteration : accept<typename State::type, S, Pos> {};
48 public:
49 typedef foldl type;
50
51 template <class S, class Pos>
52 struct apply :
53 boost::mpl::eval_if<
54 typename is_error<typename P::template apply<S, Pos> >::type,
55 next_iteration<S, Pos>,
56 apply_unchecked<typename P::template apply<S, Pos> >
57 >
58 {};
59 };
60 }
61 }
62 }
63
64 #endif
65