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_MPL_ITERATOR_05052005_0731) |
8 | #define FUSION_MPL_ITERATOR_05052005_0731 |
9 | |
10 | #include <boost/fusion/support/config.hpp> |
11 | #include <boost/fusion/support/detail/mpl_iterator_category.hpp> |
12 | #include <boost/fusion/iterator/iterator_facade.hpp> |
13 | #include <boost/type_traits/remove_const.hpp> |
14 | #include <boost/mpl/deref.hpp> |
15 | #include <boost/mpl/next.hpp> |
16 | #include <boost/mpl/prior.hpp> |
17 | #include <boost/mpl/advance.hpp> |
18 | #include <boost/mpl/distance.hpp> |
19 | |
20 | namespace boost { namespace fusion |
21 | { |
22 | template <typename Iterator_> |
23 | struct mpl_iterator |
24 | : iterator_facade< |
25 | mpl_iterator<Iterator_> |
26 | , typename detail::mpl_iterator_category<typename Iterator_::category>::type |
27 | > |
28 | { |
29 | typedef typename remove_const<Iterator_>::type iterator_type; |
30 | |
31 | template <typename Iterator> |
32 | struct value_of : mpl::deref<typename Iterator::iterator_type> {}; |
33 | |
34 | template <typename Iterator> |
35 | struct deref |
36 | { |
37 | typedef typename mpl::deref< |
38 | typename Iterator::iterator_type>::type |
39 | type; |
40 | |
41 | BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED |
42 | static type |
43 | call(Iterator) |
44 | { |
45 | return type(); |
46 | } |
47 | }; |
48 | |
49 | template <typename Iterator> |
50 | struct next |
51 | { |
52 | typedef mpl_iterator< |
53 | typename mpl::next<typename Iterator::iterator_type>::type> |
54 | type; |
55 | |
56 | BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED |
57 | static type |
58 | call(Iterator) |
59 | { |
60 | return type(); |
61 | } |
62 | }; |
63 | |
64 | template <typename Iterator> |
65 | struct prior |
66 | { |
67 | typedef mpl_iterator< |
68 | typename mpl::prior<typename Iterator::iterator_type>::type> |
69 | type; |
70 | |
71 | BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED |
72 | static type |
73 | call(Iterator) |
74 | { |
75 | return type(); |
76 | } |
77 | }; |
78 | |
79 | template <typename Iterator, typename N> |
80 | struct advance |
81 | { |
82 | typedef mpl_iterator< |
83 | typename mpl::advance<typename Iterator::iterator_type, N>::type> |
84 | type; |
85 | |
86 | BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED |
87 | static type |
88 | call(Iterator const& /*i*/) |
89 | { |
90 | return type(); |
91 | } |
92 | }; |
93 | |
94 | template <typename I1, typename I2> |
95 | struct distance : |
96 | mpl::distance< |
97 | typename I1::iterator_type |
98 | , typename I2::iterator_type> |
99 | { |
100 | typedef typename |
101 | mpl::distance< |
102 | typename I1::iterator_type |
103 | , typename I2::iterator_type |
104 | >::type |
105 | type; |
106 | |
107 | BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED |
108 | static type |
109 | call(I1 const&, I2 const&) |
110 | { |
111 | return type(); |
112 | } |
113 | }; |
114 | }; |
115 | }} |
116 | |
117 | #ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408 |
118 | namespace std |
119 | { |
120 | template <typename Iterator> |
121 | struct iterator_traits< ::boost::fusion::mpl_iterator<Iterator> > |
122 | { }; |
123 | } |
124 | #endif |
125 | |
126 | #endif |
127 | |
128 | |
129 |