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