Back to home page

EIC code displayed by LXR

 
 

    


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

0001 #ifndef BOOST_METAPARSE_V1_ACCEPT_WHEN_HPP
0002 #define BOOST_METAPARSE_V1_ACCEPT_WHEN_HPP
0003 
0004 // Copyright Abel Sinkovics (abel@sinkovics.hu)  2009 - 2010.
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/get_result.hpp>
0010 #include <boost/metaparse/v1/reject.hpp>
0011 #include <boost/metaparse/v1/is_error.hpp>
0012 
0013 #include <boost/mpl/if.hpp>
0014 #include <boost/mpl/eval_if.hpp>
0015 
0016 namespace boost
0017 {
0018   namespace metaparse
0019   {
0020     namespace v1
0021     {
0022       template <class P, class Pred, class Msg>
0023       struct accept_when
0024       {
0025       private:
0026         struct unchecked
0027         {
0028           template <class S, class Pos>
0029           struct apply :
0030             boost::mpl::eval_if<
0031               typename Pred::template apply<
0032                 typename get_result<typename P::template apply<S, Pos> >::type
0033               >::type,
0034               typename P::template apply<S, Pos>,
0035               reject<Msg, Pos>
0036             >
0037           {};
0038         };
0039       public:
0040         typedef accept_when type;
0041         
0042         template <class S, class Pos>
0043         struct apply :
0044           boost::mpl::if_<
0045             is_error<typename P::template apply<S, Pos> >,
0046             P,
0047             unchecked
0048           >::type::template apply<
0049             S,
0050             Pos
0051           >
0052         {};
0053       };
0054     }
0055   }
0056 }
0057 
0058 #endif
0059