]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /////////////////////////////////////////////////////////////////////////////// |
2 | /// \file pop_front.hpp | |
3 | /// Proto callables Fusion pop_front | |
4 | // | |
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) | |
8 | ||
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 | |
11 | ||
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> | |
17 | ||
18 | namespace boost { namespace proto { namespace functional | |
19 | { | |
20 | /// \brief A PolymorphicFunctionObject type that invokes the | |
21 | /// \c fusion::pop_front() algorithm on its argument. | |
22 | /// | |
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 | |
29 | /// the first child. | |
30 | struct pop_front | |
31 | { | |
32 | BOOST_PROTO_CALLABLE() | |
33 | ||
34 | template<typename Sig> | |
35 | struct result; | |
36 | ||
37 | template<typename This, typename Seq> | |
38 | struct result<This(Seq)> | |
39 | : result<This(Seq const &)> | |
40 | {}; | |
41 | ||
42 | template<typename This, typename Seq> | |
43 | struct result<This(Seq &)> | |
44 | : fusion::result_of::pop_front<Seq> | |
45 | {}; | |
46 | ||
47 | template<typename Seq> | |
48 | typename fusion::result_of::pop_front<Seq>::type | |
49 | operator ()(Seq &seq) const | |
50 | { | |
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)); | |
54 | } | |
55 | ||
56 | template<typename Seq> | |
57 | typename fusion::result_of::pop_front<Seq const>::type | |
58 | operator ()(Seq const &seq) const | |
59 | { | |
60 | return fusion::pop_front(seq); | |
61 | } | |
62 | }; | |
63 | }}} | |
64 | ||
65 | #endif |