at_impl.hpp 2.0 KB

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