Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:50:27

0001 ///////////////////////////////////////////////////////////////////////////////
0002 /// \file reverse.hpp
0003 /// Proto callables Fusion reverse
0004 //
0005 //  Copyright 2010 Eric Niebler. Distributed under the Boost
0006 //  Software License, Version 1.0. (See accompanying file
0007 //  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0008 
0009 #ifndef BOOST_PROTO_FUNCTIONAL_FUSION_REVERSE_HPP_EAN_11_27_2010
0010 #define BOOST_PROTO_FUNCTIONAL_FUSION_REVERSE_HPP_EAN_11_27_2010
0011 
0012 #include <boost/fusion/include/reverse.hpp>
0013 #include <boost/proto/proto_fwd.hpp>
0014 
0015 namespace boost { namespace proto { namespace functional
0016 {
0017     /// \brief A PolymorphicFunctionObject type that invokes the
0018     /// \c fusion::reverse() algorithm on its argument.
0019     ///
0020     /// A PolymorphicFunctionObject type that invokes the
0021     /// \c fusion::reverse() algorithm on its argument. This is
0022     /// useful for defining a CallableTransform like \c reverse(_)
0023     /// which reverses the order of the children of a Proto
0024     /// expression node.
0025     struct reverse
0026     {
0027         BOOST_PROTO_CALLABLE()
0028 
0029         template<typename Sig>
0030         struct result;
0031 
0032         template<typename This, typename Seq>
0033         struct result<This(Seq)>
0034           : result<This(Seq const &)>
0035         {};
0036 
0037         template<typename This, typename Seq>
0038         struct result<This(Seq &)>
0039           : fusion::result_of::reverse<Seq>
0040         {};
0041 
0042         template<typename Seq>
0043         typename fusion::result_of::reverse<Seq>::type
0044         operator ()(Seq &seq) const
0045         {
0046             // Work around a const-correctness issue in Fusion
0047             typedef typename fusion::result_of::reverse<Seq>::type result_type;
0048             return result_type(seq);
0049         }
0050 
0051         template<typename Seq>
0052         typename fusion::result_of::reverse<Seq const>::type
0053         operator ()(Seq const &seq) const
0054         {
0055             return fusion::reverse(seq);
0056         }
0057     };
0058 }}}
0059 
0060 #endif