Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:40:49

0001 #ifndef BOOST_METAPARSE_V1_FOLDL_HPP
0002 #define BOOST_METAPARSE_V1_FOLDL_HPP
0003 
0004 // Copyright Abel Sinkovics (abel@sinkovics.hu)  2011.
0005 // Distributed under the Boost Software License, Version 1.0.
0006 //    (See accompanying file LICENSE_1_0.txt or copy at
0007 //          http://www.boost.org/LICENSE_1_0.txt)
0008 
0009 #include <boost/metaparse/v1/accept.hpp>
0010 #include <boost/metaparse/v1/is_error.hpp>
0011 #include <boost/metaparse/v1/get_position.hpp>
0012 #include <boost/metaparse/v1/get_result.hpp>
0013 #include <boost/metaparse/v1/get_remaining.hpp>
0014 
0015 #include <boost/mpl/eval_if.hpp>
0016 
0017 namespace boost
0018 {
0019   namespace metaparse
0020   {
0021     namespace v1
0022     {
0023       template <class P, class State, class ForwardOp>
0024       struct foldl
0025       {
0026       private:
0027         template <class Res>
0028         struct apply_unchecked :
0029           // foldl never returns error
0030           // I need to use apply_wrap, and not apply, because apply would
0031           // build a metafunction class from foldl<P, State, ForwardOp>
0032           // when ForwardOp is a lambda expression.
0033           foldl<
0034             P,
0035             typename ForwardOp::template apply<
0036               typename State::type,
0037               typename get_result<Res>::type
0038             >,
0039             ForwardOp
0040           >::template apply<
0041             typename get_remaining<Res>::type,
0042             typename get_position<Res>::type
0043           >
0044         {};
0045 
0046         template <class S, class Pos>
0047         struct next_iteration : accept<typename State::type, S, Pos> {};
0048       public:
0049         typedef foldl type;
0050       
0051         template <class S, class Pos>
0052         struct apply :
0053           boost::mpl::eval_if<
0054             typename is_error<typename P::template apply<S, Pos> >::type,
0055             next_iteration<S, Pos>,
0056             apply_unchecked<typename P::template apply<S, Pos> >
0057           >
0058         {};
0059       };
0060     }
0061   }
0062 }
0063 
0064 #endif
0065