transform_view_iterator.hpp 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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_TRANSFORM_VIEW_ITERATOR_07162005_1033)
  7. #define FUSION_TRANSFORM_VIEW_ITERATOR_07162005_1033
  8. #include <boost/fusion/support/config.hpp>
  9. #include <boost/fusion/support/iterator_base.hpp>
  10. #include <boost/fusion/support/category_of.hpp>
  11. #include <boost/fusion/iterator/mpl/convert_iterator.hpp>
  12. #include <boost/fusion/adapted/mpl/mpl_iterator.hpp>
  13. #include <boost/fusion/view/transform_view/detail/deref_impl.hpp>
  14. #include <boost/fusion/view/transform_view/detail/next_impl.hpp>
  15. #include <boost/fusion/view/transform_view/detail/prior_impl.hpp>
  16. #include <boost/fusion/view/transform_view/detail/value_of_impl.hpp>
  17. #include <boost/fusion/view/transform_view/detail/advance_impl.hpp>
  18. #include <boost/fusion/view/transform_view/detail/distance_impl.hpp>
  19. #include <boost/fusion/view/transform_view/detail/equal_to_impl.hpp>
  20. namespace boost { namespace fusion
  21. {
  22. // Unary Version
  23. struct transform_view_iterator_tag;
  24. template <typename First, typename F>
  25. struct transform_view_iterator
  26. : iterator_base<transform_view_iterator<First, F> >
  27. {
  28. typedef transform_view_iterator_tag fusion_tag;
  29. typedef convert_iterator<First> converter;
  30. typedef typename converter::type first_type;
  31. typedef typename traits::category_of<first_type>::type category;
  32. typedef F transform_type;
  33. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  34. transform_view_iterator(First const& in_first, F const& in_f)
  35. : first(converter::call(in_first)), f(in_f) {}
  36. first_type first;
  37. transform_type f;
  38. private:
  39. // silence MSVC warning C4512: assignment operator could not be generated
  40. transform_view_iterator& operator= (transform_view_iterator const&);
  41. };
  42. // Binary Version
  43. struct transform_view_iterator2_tag;
  44. template <typename First1, typename First2, typename F>
  45. struct transform_view_iterator2
  46. : iterator_base<transform_view_iterator2<First1, First2, F> >
  47. {
  48. typedef transform_view_iterator2_tag fusion_tag;
  49. typedef convert_iterator<First1> converter1;
  50. typedef convert_iterator<First2> converter2;
  51. typedef typename converter1::type first1_type;
  52. typedef typename converter2::type first2_type;
  53. typedef typename traits::category_of<first1_type>::type category;
  54. typedef F transform_type;
  55. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  56. transform_view_iterator2(First1 const& in_first1, First2 const& in_first2, F const& in_f)
  57. : first1(converter1::call(in_first1)), first2(converter2::call(in_first2)), f(in_f) {}
  58. first1_type first1;
  59. first2_type first2;
  60. transform_type f;
  61. private:
  62. // silence MSVC warning C4512: assignment operator could not be generated
  63. transform_view_iterator2& operator= (transform_view_iterator2 const&);
  64. };
  65. }}
  66. #ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408
  67. namespace std
  68. {
  69. template <typename First, typename F>
  70. struct iterator_traits< ::boost::fusion::transform_view_iterator<First, F> >
  71. { };
  72. template <typename First1, typename First2, typename F>
  73. struct iterator_traits< ::boost::fusion::transform_view_iterator2<First1, First2, F> >
  74. { };
  75. }
  76. #endif
  77. #endif