at_impl.hpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*=============================================================================
  2. Copyright (c) 2001-2011 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_AT_IMPL_09242011_1744)
  7. #define BOOST_FUSION_AT_IMPL_09242011_1744
  8. #include <boost/fusion/support/config.hpp>
  9. #include <tuple>
  10. #include <utility>
  11. #include <boost/mpl/if.hpp>
  12. #include <boost/fusion/support/detail/access.hpp>
  13. #include <boost/type_traits/remove_const.hpp>
  14. namespace boost { namespace fusion
  15. {
  16. struct std_tuple_tag;
  17. namespace extension
  18. {
  19. template<typename T>
  20. struct at_impl;
  21. template <>
  22. struct at_impl<std_tuple_tag>
  23. {
  24. template <typename Sequence, typename N>
  25. struct apply
  26. {
  27. typedef typename remove_const<Sequence>::type seq_type;
  28. typedef typename std::tuple_element<N::value, seq_type>::type element;
  29. typedef typename
  30. mpl::if_<
  31. is_const<Sequence>
  32. , typename fusion::detail::cref_result<element>::type
  33. , typename fusion::detail::ref_result<element>::type
  34. >::type
  35. type;
  36. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  37. static type
  38. call(Sequence& seq)
  39. {
  40. return std::get<N::value>(seq);
  41. }
  42. };
  43. };
  44. }
  45. }}
  46. #endif