1 /*=============================================================================
2 Copyright (c) 2001-2011 Joel de Guzman
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_ITERATOR_ADAPTER_08112011_0942)
8 #define FUSION_ITERATOR_ADAPTER_08112011_0942
10 #include <boost/fusion/support/config.hpp>
11 #include <boost/fusion/support/category_of.hpp>
12 #include <boost/fusion/iterator/advance.hpp>
13 #include <boost/fusion/iterator/deref.hpp>
14 #include <boost/fusion/iterator/distance.hpp>
15 #include <boost/fusion/iterator/equal_to.hpp>
16 #include <boost/fusion/iterator/iterator_facade.hpp>
17 #include <boost/fusion/iterator/next.hpp>
18 #include <boost/fusion/iterator/prior.hpp>
19 #include <boost/fusion/iterator/value_of.hpp>
20 #include <boost/type_traits/remove_const.hpp>
22 namespace boost { namespace fusion
24 template <typename Derived_, typename Iterator_,
25 typename Category = typename traits::category_of<Iterator_>::type>
26 struct iterator_adapter
27 : iterator_facade<Derived_, Category>
30 remove_const<Iterator_>::type
32 iterator_base_type iterator_base;
34 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
35 iterator_adapter(iterator_base_type const& iterator_base_)
36 : iterator_base(iterator_base_) {}
38 // default implementation
39 template <typename I1, typename I2>
41 : result_of::equal_to<
42 typename I1::iterator_base_type
43 , typename I2::iterator_base_type
47 // default implementation
48 template <typename Iterator, typename N>
51 typedef typename Derived_::template make<
52 typename result_of::advance<
53 typename Iterator::iterator_base_type, N
57 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
59 call(Iterator const& it)
61 return type(fusion::advance<N>(it.iterator_base));
65 // default implementation
66 template <typename First, typename Last>
68 : result_of::distance<
69 typename First::iterator_base_type
70 , typename Last::iterator_base_type
74 // default implementation
75 template <typename Iterator>
77 : result_of::value_of<
78 typename Iterator::iterator_base_type
82 // default implementation
83 template <typename Iterator>
88 typename Iterator::iterator_base_type
92 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
94 call(Iterator const& it)
96 return fusion::deref(it.iterator_base);
100 // default implementation
101 template <typename Iterator>
104 typedef typename Derived_::template make<
105 typename result_of::next<
106 typename Iterator::iterator_base_type
110 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
112 call(Iterator const& i)
114 return type(fusion::next(i.iterator_base));
118 // default implementation
119 template <typename Iterator>
122 typedef typename Derived_::template make<
123 typename result_of::prior<
124 typename Iterator::iterator_base_type
128 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
130 call(Iterator const& i)
132 return type(fusion::prior(i.iterator_base));
138 #ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408
141 template <typename Derived, typename Iterator, typename Category>
142 struct iterator_traits< ::boost::fusion::iterator_adapter<Derived, Iterator, Category> >