1 ///////////////////////////////////////////////////////////////////////////////
2 /// \file pop_front.hpp
3 /// Proto callables Fusion pop_front
5 // Copyright 2010 Eric Niebler. Distributed under the Boost
6 // Software License, Version 1.0. (See accompanying file
7 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 #ifndef BOOST_PROTO_FUNCTIONAL_FUSION_POP_FRONT_HPP_EAN_11_27_2010
10 #define BOOST_PROTO_FUNCTIONAL_FUSION_POP_FRONT_HPP_EAN_11_27_2010
12 #include <boost/fusion/include/begin.hpp>
13 #include <boost/fusion/include/end.hpp>
14 #include <boost/fusion/include/next.hpp>
15 #include <boost/fusion/include/pop_front.hpp>
16 #include <boost/proto/proto_fwd.hpp>
18 namespace boost { namespace proto { namespace functional
20 /// \brief A PolymorphicFunctionObject type that invokes the
21 /// \c fusion::pop_front() algorithm on its argument.
23 /// A PolymorphicFunctionObject type that invokes the
24 /// \c fusion::pop_front() algorithm on its argument. This is
25 /// useful for defining a CallableTransform like \c pop_front(_)
26 /// which removes the first child from a Proto expression node.
27 /// Such a transform might be used as the first argument to the
28 /// \c proto::fold\<\> transform; that is, fold all but
32 BOOST_PROTO_CALLABLE()
34 template<typename Sig>
37 template<typename This, typename Seq>
38 struct result<This(Seq)>
39 : result<This(Seq const &)>
42 template<typename This, typename Seq>
43 struct result<This(Seq &)>
44 : fusion::result_of::pop_front<Seq>
47 template<typename Seq>
48 typename fusion::result_of::pop_front<Seq>::type
49 operator ()(Seq &seq) const
51 // Work around a const-correctness issue in Fusion
52 typedef typename fusion::result_of::pop_front<Seq>::type result_type;
53 return result_type(fusion::next(fusion::begin(seq)), fusion::end(seq));
56 template<typename Seq>
57 typename fusion::result_of::pop_front<Seq const>::type
58 operator ()(Seq const &seq) const
60 return fusion::pop_front(seq);