• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 ///////////////////////////////////////////////////////////////////////////////
2 /// \file at.hpp
3 /// Proto callables Fusion at
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_AT_HPP_EAN_11_27_2010
10 #define BOOST_PROTO_FUNCTIONAL_FUSION_AT_HPP_EAN_11_27_2010
11 
12 #include <boost/type_traits/add_const.hpp>
13 #include <boost/type_traits/remove_const.hpp>
14 #include <boost/type_traits/remove_reference.hpp>
15 #include <boost/fusion/include/at.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::at() accessor on its argument.
22     ///
23     /// A PolymorphicFunctionObject type that invokes the
24     /// \c fusion::at() accessor on its argument.
25     struct at
26     {
27         BOOST_PROTO_CALLABLE()
28 
29         template<typename Sig>
30         struct result;
31 
32         template<typename This, typename Seq, typename N>
33         struct result<This(Seq, N)>
34           : fusion::result_of::at<
35                 typename boost::remove_reference<Seq>::type
36               , typename boost::remove_const<typename boost::remove_reference<N>::type>::type
37             >
38         {};
39 
40         template<typename Seq, typename N>
41         typename fusion::result_of::at<Seq, N>::type
operator ()boost::proto::functional::at42         operator ()(Seq &seq, N const & BOOST_PROTO_DISABLE_IF_IS_CONST(Seq)) const
43         {
44             return fusion::at<N>(seq);
45         }
46 
47         template<typename Seq, typename N>
48         typename fusion::result_of::at<Seq const, N>::type
operator ()boost::proto::functional::at49         operator ()(Seq const &seq, N const &) const
50         {
51             return fusion::at<N>(seq);
52         }
53     };
54 }}}
55 
56 #endif
57