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