deref_impl.hpp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*=============================================================================
  2. Copyright (c) 2001-2011 Joel de Guzman
  3. Copyright (c) 2006 Dan Marsden
  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_20061024_1959)
  8. #define FUSION_DEREF_IMPL_20061024_1959
  9. #include <boost/fusion/support/config.hpp>
  10. #include <boost/fusion/container/vector.hpp>
  11. #include <boost/fusion/iterator/deref.hpp>
  12. #include <boost/fusion/algorithm/transformation/transform.hpp>
  13. #include <boost/fusion/container/vector/convert.hpp>
  14. #include <boost/fusion/support/unused.hpp>
  15. #include <boost/mpl/eval_if.hpp>
  16. #include <boost/mpl/identity.hpp>
  17. #include <boost/type_traits/is_same.hpp>
  18. #include <boost/type_traits/remove_reference.hpp>
  19. #include <boost/type_traits/remove_const.hpp>
  20. namespace boost { namespace fusion {
  21. struct zip_view_iterator_tag;
  22. namespace detail
  23. {
  24. struct poly_deref
  25. {
  26. template<typename Sig>
  27. struct result;
  28. template<typename It>
  29. struct result<poly_deref(It)>
  30. {
  31. typedef typename remove_const<
  32. typename remove_reference<It>::type>::type it;
  33. typedef typename mpl::eval_if<is_same<it, unused_type>,
  34. mpl::identity<unused_type>,
  35. result_of::deref<it> >::type type;
  36. };
  37. template<typename It>
  38. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  39. typename result<poly_deref(It)>::type
  40. operator()(const It& it) const
  41. {
  42. return fusion::deref(it);
  43. }
  44. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  45. unused_type operator()(unused_type const&) const
  46. {
  47. return unused_type();
  48. }
  49. };
  50. }
  51. namespace extension
  52. {
  53. template<typename Tag>
  54. struct deref_impl;
  55. template<>
  56. struct deref_impl<zip_view_iterator_tag>
  57. {
  58. template<typename It>
  59. struct apply
  60. {
  61. typedef typename result_of::as_vector<
  62. typename result_of::transform<typename It::iterators, detail::poly_deref>::type>::type type;
  63. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  64. static type
  65. call(It const& it)
  66. {
  67. return type(
  68. fusion::transform(it.iterators_, detail::poly_deref()));
  69. }
  70. };
  71. };
  72. }
  73. }}
  74. #endif