Chris@16
|
1 ///////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
2 /// \file pop_back.hpp
|
Chris@16
|
3 /// Proto callables Fusion pop_back
|
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_BACK_HPP_EAN_11_27_2010
|
Chris@16
|
10 #define BOOST_PROTO_FUNCTIONAL_FUSION_POP_BACK_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/prior.hpp>
|
Chris@16
|
15 #include <boost/fusion/include/pop_back.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_back() algorithm on its argument.
|
Chris@16
|
22 ///
|
Chris@16
|
23 /// A PolymorphicFunctionObject type that invokes the
|
Chris@16
|
24 /// \c fusion::pop_back() algorithm on its argument.
|
Chris@16
|
25 struct pop_back
|
Chris@16
|
26 {
|
Chris@16
|
27 BOOST_PROTO_CALLABLE()
|
Chris@16
|
28
|
Chris@16
|
29 template<typename Sig>
|
Chris@16
|
30 struct result;
|
Chris@16
|
31
|
Chris@16
|
32 template<typename This, typename Seq>
|
Chris@16
|
33 struct result<This(Seq)>
|
Chris@16
|
34 : result<This(Seq const &)>
|
Chris@16
|
35 {};
|
Chris@16
|
36
|
Chris@16
|
37 template<typename This, typename Seq>
|
Chris@16
|
38 struct result<This(Seq &)>
|
Chris@16
|
39 : fusion::result_of::pop_back<Seq>
|
Chris@16
|
40 {};
|
Chris@16
|
41
|
Chris@16
|
42 template<typename Seq>
|
Chris@16
|
43 typename fusion::result_of::pop_back<Seq>::type
|
Chris@16
|
44 operator ()(Seq &seq) const
|
Chris@16
|
45 {
|
Chris@16
|
46 // Work around a const-correctness issue in Fusion
|
Chris@16
|
47 typedef typename fusion::result_of::pop_back<Seq>::type result_type;
|
Chris@16
|
48 return result_type(fusion::begin(seq), fusion::prior(fusion::end(seq)));
|
Chris@16
|
49 }
|
Chris@16
|
50
|
Chris@16
|
51 template<typename Seq>
|
Chris@16
|
52 typename fusion::result_of::pop_back<Seq const>::type
|
Chris@16
|
53 operator ()(Seq const &seq) const
|
Chris@16
|
54 {
|
Chris@16
|
55 return fusion::pop_back(seq);
|
Chris@16
|
56 }
|
Chris@16
|
57 };
|
Chris@16
|
58 }}}
|
Chris@16
|
59
|
Chris@16
|
60 #endif
|