at_impl.hpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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/detail/access.hpp>
  9. namespace boost { namespace fusion
  10. {
  11. struct map_tag;
  12. namespace extension
  13. {
  14. template <typename Tag>
  15. struct at_impl;
  16. template <>
  17. struct at_impl<map_tag>
  18. {
  19. template <typename Sequence, typename N>
  20. struct apply
  21. {
  22. typedef mpl::int_<N::value> index;
  23. typedef
  24. decltype(std::declval<Sequence>().get(index()))
  25. type;
  26. static type
  27. call(Sequence& m)
  28. {
  29. return m.get(index());
  30. }
  31. };
  32. template <typename Sequence, typename N>
  33. struct apply<Sequence const, N>
  34. {
  35. typedef mpl::int_<N::value> index;
  36. typedef
  37. decltype(std::declval<Sequence const>().get(index()))
  38. type;
  39. static type
  40. call(Sequence const& m)
  41. {
  42. return m.get(index());
  43. }
  44. };
  45. };
  46. }
  47. }}
  48. #endif