at.hpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. #ifndef BOOST_PROTO_FUNCTIONAL_FUSION_AT_HPP_EAN_11_27_2010
  9. #define BOOST_PROTO_FUNCTIONAL_FUSION_AT_HPP_EAN_11_27_2010
  10. #include <boost/type_traits/add_const.hpp>
  11. #include <boost/type_traits/remove_const.hpp>
  12. #include <boost/type_traits/remove_reference.hpp>
  13. #include <boost/fusion/include/at.hpp>
  14. #include <boost/proto/proto_fwd.hpp>
  15. namespace boost { namespace proto { namespace functional
  16. {
  17. /// \brief A PolymorphicFunctionObject type that invokes the
  18. /// \c fusion::at() accessor on its argument.
  19. ///
  20. /// A PolymorphicFunctionObject type that invokes the
  21. /// \c fusion::at() accessor on its argument.
  22. struct at
  23. {
  24. BOOST_PROTO_CALLABLE()
  25. template<typename Sig>
  26. struct result;
  27. template<typename This, typename Seq, typename N>
  28. struct result<This(Seq, N)>
  29. : fusion::result_of::at<
  30. typename boost::remove_reference<Seq>::type
  31. , typename boost::remove_const<typename boost::remove_reference<N>::type>::type
  32. >
  33. {};
  34. template<typename Seq, typename N>
  35. typename fusion::result_of::at<Seq, N>::type
  36. operator ()(Seq &seq, N const & BOOST_PROTO_DISABLE_IF_IS_CONST(Seq)) const
  37. {
  38. return fusion::at<N>(seq);
  39. }
  40. template<typename Seq, typename N>
  41. typename fusion::result_of::at<Seq const, N>::type
  42. operator ()(Seq const &seq, N const &) const
  43. {
  44. return fusion::at<N>(seq);
  45. }
  46. };
  47. }}}
  48. #endif