Chris@16
|
1 ///////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
2 /// \file reverse.hpp
|
Chris@16
|
3 /// Proto callables Fusion reverse
|
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_REVERSE_HPP_EAN_11_27_2010
|
Chris@16
|
10 #define BOOST_PROTO_FUNCTIONAL_FUSION_REVERSE_HPP_EAN_11_27_2010
|
Chris@16
|
11
|
Chris@16
|
12 #include <boost/fusion/include/reverse.hpp>
|
Chris@16
|
13 #include <boost/proto/proto_fwd.hpp>
|
Chris@16
|
14
|
Chris@16
|
15 namespace boost { namespace proto { namespace functional
|
Chris@16
|
16 {
|
Chris@16
|
17 /// \brief A PolymorphicFunctionObject type that invokes the
|
Chris@16
|
18 /// \c fusion::reverse() algorithm on its argument.
|
Chris@16
|
19 ///
|
Chris@16
|
20 /// A PolymorphicFunctionObject type that invokes the
|
Chris@16
|
21 /// \c fusion::reverse() algorithm on its argument. This is
|
Chris@16
|
22 /// useful for defining a CallableTransform like \c reverse(_)
|
Chris@16
|
23 /// which reverses the order of the children of a Proto
|
Chris@16
|
24 /// expression node.
|
Chris@16
|
25 struct reverse
|
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::reverse<Seq>
|
Chris@16
|
40 {};
|
Chris@16
|
41
|
Chris@16
|
42 template<typename Seq>
|
Chris@16
|
43 typename fusion::result_of::reverse<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::reverse<Seq>::type result_type;
|
Chris@16
|
48 return result_type(seq);
|
Chris@16
|
49 }
|
Chris@16
|
50
|
Chris@16
|
51 template<typename Seq>
|
Chris@16
|
52 typename fusion::result_of::reverse<Seq const>::type
|
Chris@16
|
53 operator ()(Seq const &seq) const
|
Chris@16
|
54 {
|
Chris@16
|
55 return fusion::reverse(seq);
|
Chris@16
|
56 }
|
Chris@16
|
57 };
|
Chris@16
|
58 }}}
|
Chris@16
|
59
|
Chris@16
|
60 #endif
|