advance_impl.hpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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_ADVANCE_IMPL_20061024_2021)
  8. #define FUSION_ADVANCE_IMPL_20061024_2021
  9. #include <boost/fusion/support/config.hpp>
  10. #include <boost/fusion/view/zip_view/zip_view_iterator_fwd.hpp>
  11. #include <boost/fusion/iterator/advance.hpp>
  12. #include <boost/fusion/algorithm/transformation/transform.hpp>
  13. #include <boost/type_traits/remove_reference.hpp>
  14. namespace boost { namespace fusion {
  15. struct zip_view_iterator_tag;
  16. namespace detail
  17. {
  18. template<typename N>
  19. struct poly_advance
  20. {
  21. template<typename Sig>
  22. struct result;
  23. template<typename N1, typename It>
  24. struct result<poly_advance<N1>(It)>
  25. {
  26. typedef typename remove_reference<It>::type it;
  27. typedef typename result_of::advance<it,N>::type type;
  28. };
  29. template<typename It>
  30. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  31. typename result<poly_advance(It)>::type
  32. operator()(const It& it) const
  33. {
  34. return fusion::advance<N>(it);
  35. }
  36. };
  37. }
  38. namespace extension
  39. {
  40. template<typename Tag>
  41. struct advance_impl;
  42. template<>
  43. struct advance_impl<zip_view_iterator_tag>
  44. {
  45. template<typename It, typename N>
  46. struct apply
  47. {
  48. typedef zip_view_iterator<
  49. typename result_of::transform<typename It::iterators, detail::poly_advance<N> >::type> type;
  50. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  51. static type
  52. call(It const& it)
  53. {
  54. return type(
  55. fusion::transform(it.iterators_, detail::poly_advance<N>()));
  56. }
  57. };
  58. };
  59. }
  60. }}
  61. #endif