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