Chris@16
|
1 /*=============================================================================
|
Chris@16
|
2 Copyright (c) 2001-2011 Joel de Guzman
|
Chris@16
|
3
|
Chris@16
|
4 Distributed under the Boost Software License, Version 1.0. (See accompanying
|
Chris@16
|
5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
6 ==============================================================================*/
|
Chris@16
|
7 #if !defined(FUSION_ITERATOR_ADAPTER_08112011_0942)
|
Chris@16
|
8 #define FUSION_ITERATOR_ADAPTER_08112011_0942
|
Chris@16
|
9
|
Chris@101
|
10 #include <boost/fusion/support/config.hpp>
|
Chris@101
|
11 #include <boost/fusion/support/category_of.hpp>
|
Chris@101
|
12 #include <boost/fusion/iterator/advance.hpp>
|
Chris@101
|
13 #include <boost/fusion/iterator/deref.hpp>
|
Chris@101
|
14 #include <boost/fusion/iterator/distance.hpp>
|
Chris@101
|
15 #include <boost/fusion/iterator/equal_to.hpp>
|
Chris@16
|
16 #include <boost/fusion/iterator/iterator_facade.hpp>
|
Chris@101
|
17 #include <boost/fusion/iterator/next.hpp>
|
Chris@101
|
18 #include <boost/fusion/iterator/prior.hpp>
|
Chris@101
|
19 #include <boost/fusion/iterator/value_of.hpp>
|
Chris@16
|
20 #include <boost/type_traits/remove_const.hpp>
|
Chris@16
|
21
|
Chris@16
|
22 namespace boost { namespace fusion
|
Chris@16
|
23 {
|
Chris@16
|
24 template <typename Derived_, typename Iterator_,
|
Chris@101
|
25 typename Category = typename traits::category_of<Iterator_>::type>
|
Chris@16
|
26 struct iterator_adapter
|
Chris@16
|
27 : iterator_facade<Derived_, Category>
|
Chris@16
|
28 {
|
Chris@16
|
29 typedef typename
|
Chris@16
|
30 remove_const<Iterator_>::type
|
Chris@16
|
31 iterator_base_type;
|
Chris@16
|
32 iterator_base_type iterator_base;
|
Chris@16
|
33
|
Chris@101
|
34 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
Chris@16
|
35 iterator_adapter(iterator_base_type const& iterator_base_)
|
Chris@16
|
36 : iterator_base(iterator_base_) {}
|
Chris@16
|
37
|
Chris@16
|
38 // default implementation
|
Chris@16
|
39 template <typename I1, typename I2>
|
Chris@16
|
40 struct equal_to
|
Chris@16
|
41 : result_of::equal_to<
|
Chris@16
|
42 typename I1::iterator_base_type
|
Chris@16
|
43 , typename I2::iterator_base_type
|
Chris@16
|
44 >
|
Chris@16
|
45 {};
|
Chris@16
|
46
|
Chris@16
|
47 // default implementation
|
Chris@16
|
48 template <typename Iterator, typename N>
|
Chris@16
|
49 struct advance
|
Chris@16
|
50 {
|
Chris@16
|
51 typedef typename Derived_::template make<
|
Chris@16
|
52 typename result_of::advance<
|
Chris@16
|
53 typename Iterator::iterator_base_type, N
|
Chris@16
|
54 >::type>::type
|
Chris@16
|
55 type;
|
Chris@16
|
56
|
Chris@101
|
57 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
Chris@16
|
58 static type
|
Chris@16
|
59 call(Iterator const& it)
|
Chris@16
|
60 {
|
Chris@16
|
61 return type(fusion::advance<N>(it.iterator_base));
|
Chris@16
|
62 }
|
Chris@16
|
63 };
|
Chris@16
|
64
|
Chris@16
|
65 // default implementation
|
Chris@16
|
66 template <typename First, typename Last>
|
Chris@16
|
67 struct distance
|
Chris@16
|
68 : result_of::distance<
|
Chris@16
|
69 typename First::iterator_base_type
|
Chris@16
|
70 , typename Last::iterator_base_type
|
Chris@16
|
71 >
|
Chris@16
|
72 {};
|
Chris@16
|
73
|
Chris@16
|
74 // default implementation
|
Chris@16
|
75 template <typename Iterator>
|
Chris@16
|
76 struct value_of
|
Chris@16
|
77 : result_of::value_of<
|
Chris@16
|
78 typename Iterator::iterator_base_type
|
Chris@16
|
79 >
|
Chris@16
|
80 {};
|
Chris@16
|
81
|
Chris@16
|
82 // default implementation
|
Chris@16
|
83 template <typename Iterator>
|
Chris@16
|
84 struct deref
|
Chris@16
|
85 {
|
Chris@16
|
86 typedef typename
|
Chris@16
|
87 result_of::deref<
|
Chris@16
|
88 typename Iterator::iterator_base_type
|
Chris@16
|
89 >::type
|
Chris@16
|
90 type;
|
Chris@16
|
91
|
Chris@101
|
92 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
Chris@16
|
93 static type
|
Chris@16
|
94 call(Iterator const& it)
|
Chris@16
|
95 {
|
Chris@16
|
96 return fusion::deref(it.iterator_base);
|
Chris@16
|
97 }
|
Chris@16
|
98 };
|
Chris@16
|
99
|
Chris@16
|
100 // default implementation
|
Chris@16
|
101 template <typename Iterator>
|
Chris@16
|
102 struct next
|
Chris@16
|
103 {
|
Chris@16
|
104 typedef typename Derived_::template make<
|
Chris@16
|
105 typename result_of::next<
|
Chris@16
|
106 typename Iterator::iterator_base_type
|
Chris@16
|
107 >::type>::type
|
Chris@16
|
108 type;
|
Chris@16
|
109
|
Chris@101
|
110 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
Chris@16
|
111 static type
|
Chris@16
|
112 call(Iterator const& i)
|
Chris@16
|
113 {
|
Chris@16
|
114 return type(fusion::next(i.iterator_base));
|
Chris@16
|
115 }
|
Chris@16
|
116 };
|
Chris@16
|
117
|
Chris@16
|
118 // default implementation
|
Chris@16
|
119 template <typename Iterator>
|
Chris@16
|
120 struct prior
|
Chris@16
|
121 {
|
Chris@16
|
122 typedef typename Derived_::template make<
|
Chris@16
|
123 typename result_of::prior<
|
Chris@16
|
124 typename Iterator::iterator_base_type
|
Chris@16
|
125 >::type>::type
|
Chris@16
|
126 type;
|
Chris@16
|
127
|
Chris@101
|
128 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
Chris@16
|
129 static type
|
Chris@16
|
130 call(Iterator const& i)
|
Chris@16
|
131 {
|
Chris@16
|
132 return type(fusion::prior(i.iterator_base));
|
Chris@16
|
133 }
|
Chris@16
|
134 };
|
Chris@16
|
135 };
|
Chris@16
|
136 }}
|
Chris@16
|
137
|
Chris@101
|
138 #ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408
|
Chris@101
|
139 namespace std
|
Chris@101
|
140 {
|
Chris@101
|
141 template <typename Derived, typename Iterator, typename Category>
|
Chris@101
|
142 struct iterator_traits< ::boost::fusion::iterator_adapter<Derived, Iterator, Category> >
|
Chris@101
|
143 { };
|
Chris@101
|
144 }
|
Chris@16
|
145 #endif
|
Chris@101
|
146
|
Chris@101
|
147 #endif
|