deref_impl.hpp 1.7 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(FUSION_DEREF_IMPL_05042005_1037)
  7. #define FUSION_DEREF_IMPL_05042005_1037
  8. #include <boost/fusion/support/config.hpp>
  9. #include <boost/fusion/support/detail/access.hpp>
  10. #include <boost/fusion/container/vector/detail/value_at_impl.hpp>
  11. #include <boost/type_traits/is_const.hpp>
  12. #include <boost/mpl/if.hpp>
  13. namespace boost { namespace fusion
  14. {
  15. struct vector_iterator_tag;
  16. namespace extension
  17. {
  18. template <typename Tag>
  19. struct deref_impl;
  20. template <>
  21. struct deref_impl<vector_iterator_tag>
  22. {
  23. template <typename Iterator>
  24. struct apply
  25. {
  26. typedef typename Iterator::vector vector;
  27. typedef typename Iterator::index index;
  28. typedef typename value_at_impl<vector_tag>::template apply<vector, index>::type element;
  29. typedef typename
  30. mpl::if_<
  31. is_const<vector>
  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(Iterator const& i)
  39. {
  40. return i.vec.at_impl(index());
  41. }
  42. };
  43. };
  44. }
  45. }}
  46. #endif