advance_impl.hpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*=============================================================================
  2. Copyright (c) 2001-2011 Joel de Guzman
  3. Copyright (c) 2005-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_13122005_1906)
  8. #define FUSION_ADVANCE_IMPL_13122005_1906
  9. #include <boost/fusion/support/config.hpp>
  10. #include <boost/fusion/iterator/advance.hpp>
  11. namespace boost { namespace fusion
  12. {
  13. struct transform_view_iterator_tag;
  14. struct transform_view_iterator2_tag;
  15. template<typename First, typename F>
  16. struct transform_view_iterator;
  17. template <typename First1, typename First2, typename F>
  18. struct transform_view_iterator2;
  19. namespace extension
  20. {
  21. template<typename Tag>
  22. struct advance_impl;
  23. // Unary Version
  24. template<>
  25. struct advance_impl<transform_view_iterator_tag>
  26. {
  27. template<typename Iterator, typename Dist>
  28. struct apply
  29. {
  30. typedef typename Iterator::first_type first_type;
  31. typedef typename result_of::advance<first_type, Dist>::type advanced_type;
  32. typedef typename Iterator::transform_type transform_type;
  33. typedef transform_view_iterator<advanced_type, transform_type> type;
  34. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  35. static type
  36. call(Iterator const& i)
  37. {
  38. return type(boost::fusion::advance<Dist>(i.first), i.f);
  39. }
  40. };
  41. };
  42. // Binary Version
  43. template<>
  44. struct advance_impl<transform_view_iterator2_tag>
  45. {
  46. template<typename Iterator, typename Dist>
  47. struct apply
  48. {
  49. typedef typename Iterator::first1_type first1_type;
  50. typedef typename Iterator::first2_type first2_type;
  51. typedef typename result_of::advance<first1_type, Dist>::type advanced1_type;
  52. typedef typename result_of::advance<first2_type, Dist>::type advanced2_type;
  53. typedef typename Iterator::transform_type transform_type;
  54. typedef transform_view_iterator2<advanced1_type, advanced2_type, transform_type> type;
  55. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  56. static type
  57. call(Iterator const& i)
  58. {
  59. return type(
  60. boost::fusion::advance<Dist>(i.first1)
  61. , boost::fusion::advance<Dist>(i.first2), i.f);
  62. }
  63. };
  64. };
  65. }
  66. }}
  67. #endif