Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:50:27

0001 ///////////////////////////////////////////////////////////////////////////////
0002 /// \file pop_front.hpp
0003 /// Proto callables Fusion pop_front
0004 //
0005 //  Copyright 2010 Eric Niebler. Distributed under the Boost
0006 //  Software License, Version 1.0. (See accompanying file
0007 //  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0008 
0009 #ifndef BOOST_PROTO_FUNCTIONAL_FUSION_POP_FRONT_HPP_EAN_11_27_2010
0010 #define BOOST_PROTO_FUNCTIONAL_FUSION_POP_FRONT_HPP_EAN_11_27_2010
0011 
0012 #include <boost/fusion/include/begin.hpp>
0013 #include <boost/fusion/include/end.hpp>
0014 #include <boost/fusion/include/next.hpp>
0015 #include <boost/fusion/include/pop_front.hpp>
0016 #include <boost/proto/proto_fwd.hpp>
0017 
0018 namespace boost { namespace proto { namespace functional
0019 {
0020     /// \brief A PolymorphicFunctionObject type that invokes the
0021     /// \c fusion::pop_front() algorithm on its argument.
0022     ///
0023     /// A PolymorphicFunctionObject type that invokes the
0024     /// \c fusion::pop_front() algorithm on its argument. This is
0025     /// useful for defining a CallableTransform like \c pop_front(_)
0026     /// which removes the first child from a Proto expression node.
0027     /// Such a transform might be used as the first argument to the
0028     /// \c proto::fold\<\> transform; that is, fold all but
0029     /// the first child.
0030     struct pop_front
0031     {
0032         BOOST_PROTO_CALLABLE()
0033 
0034         template<typename Sig>
0035         struct result;
0036 
0037         template<typename This, typename Seq>
0038         struct result<This(Seq)>
0039           : result<This(Seq const &)>
0040         {};
0041 
0042         template<typename This, typename Seq>
0043         struct result<This(Seq &)>
0044           : fusion::result_of::pop_front<Seq>
0045         {};
0046 
0047         template<typename Seq>
0048         typename fusion::result_of::pop_front<Seq>::type
0049         operator ()(Seq &seq) const
0050         {
0051             // Work around a const-correctness issue in Fusion
0052             typedef typename fusion::result_of::pop_front<Seq>::type result_type;
0053             return result_type(fusion::next(fusion::begin(seq)), fusion::end(seq));
0054         }
0055 
0056         template<typename Seq>
0057         typename fusion::result_of::pop_front<Seq const>::type
0058         operator ()(Seq const &seq) const
0059         {
0060             return fusion::pop_front(seq);
0061         }
0062     };
0063 }}}
0064 
0065 #endif