deref_impl.hpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*=============================================================================
  2. Copyright (c) 2001-2011 Joel de Guzman
  3. Copyright (c) 2005 Eric Niebler
  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(FUSION_DEREF_IMPL_07172005_0831)
  8. #define FUSION_DEREF_IMPL_07172005_0831
  9. #include <boost/fusion/support/config.hpp>
  10. #include <boost/mpl/eval_if.hpp>
  11. #include <boost/type_traits/is_const.hpp>
  12. #include <boost/type_traits/add_const.hpp>
  13. #include <boost/type_traits/add_reference.hpp>
  14. namespace boost { namespace fusion
  15. {
  16. struct cons_iterator_tag;
  17. namespace extension
  18. {
  19. template <typename Tag>
  20. struct deref_impl;
  21. template <>
  22. struct deref_impl<cons_iterator_tag>
  23. {
  24. template <typename Iterator>
  25. struct apply
  26. {
  27. typedef typename Iterator::cons_type cons_type;
  28. typedef typename cons_type::car_type value_type;
  29. typedef typename mpl::eval_if<
  30. is_const<cons_type>
  31. , add_reference<typename add_const<value_type>::type>
  32. , add_reference<value_type> >::type
  33. type;
  34. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  35. static type
  36. call(Iterator const& i)
  37. {
  38. return i.cons.car;
  39. }
  40. };
  41. };
  42. }
  43. }}
  44. #endif