| 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 | #include <boost/fusion/view/transform_view/detail/key_of_impl.hpp> |
| 23 | #include <boost/fusion/view/transform_view/detail/value_of_data_impl.hpp> |
| 24 | #include <boost/fusion/view/transform_view/detail/deref_data_impl.hpp> |
| 25 | |
| 26 | #ifdef _MSC_VER |
| 27 | # pragma warning(push) |
| 28 | # pragma warning(disable: 4512) // assignment operator could not be generated. |
| 29 | #endif |
| 30 | |
| 31 | namespace boost { namespace fusion |
| 32 | { |
| 33 | // Unary Version |
| 34 | struct transform_view_iterator_tag; |
| 35 | |
| 36 | template <typename First, typename F> |
| 37 | struct transform_view_iterator |
| 38 | : iterator_base<transform_view_iterator<First, F> > |
| 39 | { |
| 40 | typedef transform_view_iterator_tag fusion_tag; |
| 41 | typedef convert_iterator<First> converter; |
| 42 | typedef typename converter::type first_type; |
| 43 | typedef typename traits::category_of<first_type>::type category; |
| 44 | typedef F transform_type; |
| 45 | |
| 46 | BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED |
| 47 | transform_view_iterator(First const& in_first, F const& in_f) |
| 48 | : first(converter::call(in_first)), f(in_f) {} |
| 49 | |
| 50 | first_type first; |
| 51 | transform_type f; |
| 52 | }; |
| 53 | |
| 54 | // Binary Version |
| 55 | struct transform_view_iterator2_tag; |
| 56 | |
| 57 | template <typename First1, typename First2, typename F> |
| 58 | struct transform_view_iterator2 |
| 59 | : iterator_base<transform_view_iterator2<First1, First2, F> > |
| 60 | { |
| 61 | typedef transform_view_iterator2_tag fusion_tag; |
| 62 | typedef convert_iterator<First1> converter1; |
| 63 | typedef convert_iterator<First2> converter2; |
| 64 | typedef typename converter1::type first1_type; |
| 65 | typedef typename converter2::type first2_type; |
| 66 | typedef typename traits::category_of<first1_type>::type category; |
| 67 | typedef F transform_type; |
| 68 | |
| 69 | BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED |
| 70 | transform_view_iterator2(First1 const& in_first1, First2 const& in_first2, F const& in_f) |
| 71 | : first1(converter1::call(in_first1)), first2(converter2::call(in_first2)), f(in_f) {} |
| 72 | |
| 73 | first1_type first1; |
| 74 | first2_type first2; |
| 75 | transform_type f; |
| 76 | }; |
| 77 | }} |
| 78 | |
| 79 | #ifdef _MSC_VER |
| 80 | # pragma warning(pop) |
| 81 | #endif |
| 82 | |
| 83 | #ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408 |
| 84 | namespace std |
| 85 | { |
| 86 | template <typename First, typename F> |
| 87 | struct iterator_traits< ::boost::fusion::transform_view_iterator<First, F> > |
| 88 | { }; |
| 89 | template <typename First1, typename First2, typename F> |
| 90 | struct iterator_traits< ::boost::fusion::transform_view_iterator2<First1, First2, F> > |
| 91 | { }; |
| 92 | } |
| 93 | #endif |
| 94 | |
| 95 | #endif |
| 96 | |
| 97 | |