9
3

at_key_impl.hpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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_KEY_IMPL_02042013_0821)
  7. #define BOOST_FUSION_MAP_DETAIL_AT_KEY_IMPL_02042013_0821
  8. #include <boost/fusion/support/config.hpp>
  9. #include <boost/fusion/support/detail/access.hpp>
  10. #include <boost/type_traits/is_const.hpp>
  11. #include <boost/mpl/at.hpp>
  12. #include <boost/mpl/identity.hpp>
  13. #include <boost/utility/declval.hpp>
  14. namespace boost { namespace fusion
  15. {
  16. struct map_tag;
  17. namespace extension
  18. {
  19. template <typename Tag>
  20. struct at_key_impl;
  21. template <>
  22. struct at_key_impl<map_tag>
  23. {
  24. template <typename Sequence, typename Key>
  25. struct apply
  26. {
  27. typedef
  28. decltype(boost::declval<Sequence>().get(mpl::identity<Key>()))
  29. type;
  30. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  31. static type
  32. call(Sequence& m)
  33. {
  34. return m.get(mpl::identity<Key>());
  35. }
  36. };
  37. template <typename Sequence, typename Key>
  38. struct apply<Sequence const, Key>
  39. {
  40. typedef
  41. decltype(boost::declval<Sequence const>().get(mpl::identity<Key>()))
  42. type;
  43. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  44. static type
  45. call(Sequence const& m)
  46. {
  47. return m.get(mpl::identity<Key>());
  48. }
  49. };
  50. };
  51. }
  52. }}
  53. #endif