at_impl.hpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*=============================================================================
  2. Copyright (c) 2001-2013 Joel de Guzman
  3. Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. ==============================================================================*/
  6. #if !defined(BOOST_FUSION_MAP_DETAIL_AT_IMPL_02042013_0821)
  7. #define BOOST_FUSION_MAP_DETAIL_AT_IMPL_02042013_0821
  8. #include <boost/fusion/support/config.hpp>
  9. #include <boost/fusion/support/detail/access.hpp>
  10. #include <boost/utility/declval.hpp>
  11. namespace boost { namespace fusion
  12. {
  13. struct map_tag;
  14. namespace extension
  15. {
  16. template <typename Tag>
  17. struct at_impl;
  18. template <>
  19. struct at_impl<map_tag>
  20. {
  21. template <typename Sequence, typename N>
  22. struct apply
  23. {
  24. typedef mpl::int_<N::value> index;
  25. typedef
  26. decltype(boost::declval<Sequence>().get(index()))
  27. type;
  28. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  29. static type
  30. call(Sequence& m)
  31. {
  32. return m.get(index());
  33. }
  34. };
  35. template <typename Sequence, typename N>
  36. struct apply<Sequence const, N>
  37. {
  38. typedef mpl::int_<N::value> index;
  39. typedef
  40. decltype(boost::declval<Sequence const>().get(index()))
  41. type;
  42. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  43. static type
  44. call(Sequence const& m)
  45. {
  46. return m.get(index());
  47. }
  48. };
  49. };
  50. }
  51. }}
  52. #endif