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_ADVANCE_09172005_1149)
|
Chris@16
|
8 #define FUSION_ADVANCE_09172005_1149
|
Chris@16
|
9
|
Chris@101
|
10 #include <boost/fusion/support/config.hpp>
|
Chris@16
|
11 #include <boost/mpl/int.hpp>
|
Chris@16
|
12 #include <boost/mpl/if.hpp>
|
Chris@16
|
13 #include <boost/mpl/eval_if.hpp>
|
Chris@16
|
14 #include <boost/mpl/identity.hpp>
|
Chris@16
|
15 #include <boost/fusion/iterator/next.hpp>
|
Chris@16
|
16 #include <boost/fusion/iterator/prior.hpp>
|
Chris@16
|
17
|
Chris@16
|
18 namespace boost { namespace fusion { namespace advance_detail
|
Chris@16
|
19 {
|
Chris@16
|
20 // Default advance implementation, perform next(i)
|
Chris@16
|
21 // or prior(i) N times.
|
Chris@16
|
22
|
Chris@16
|
23 template <typename Iterator, int N>
|
Chris@16
|
24 struct forward;
|
Chris@16
|
25
|
Chris@16
|
26 template <typename Iterator, int N>
|
Chris@16
|
27 struct next_forward
|
Chris@16
|
28 {
|
Chris@16
|
29 typedef typename
|
Chris@16
|
30 forward<
|
Chris@16
|
31 typename result_of::next<Iterator>::type
|
Chris@16
|
32 , N-1
|
Chris@16
|
33 >::type
|
Chris@16
|
34 type;
|
Chris@16
|
35 };
|
Chris@16
|
36
|
Chris@16
|
37 template <typename Iterator, int N>
|
Chris@16
|
38 struct forward
|
Chris@16
|
39 {
|
Chris@16
|
40 typedef typename
|
Chris@16
|
41 mpl::eval_if_c<
|
Chris@16
|
42 (N == 0)
|
Chris@16
|
43 , mpl::identity<Iterator>
|
Chris@16
|
44 , next_forward<Iterator, N>
|
Chris@16
|
45 >::type
|
Chris@16
|
46 type;
|
Chris@16
|
47
|
Chris@101
|
48 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
Chris@16
|
49 static type const&
|
Chris@16
|
50 call(type const& i)
|
Chris@16
|
51 {
|
Chris@16
|
52 return i;
|
Chris@16
|
53 }
|
Chris@16
|
54
|
Chris@16
|
55 template <typename I>
|
Chris@101
|
56 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
Chris@16
|
57 static type
|
Chris@16
|
58 call(I const& i)
|
Chris@16
|
59 {
|
Chris@16
|
60 return call(fusion::next(i));
|
Chris@16
|
61 }
|
Chris@16
|
62 };
|
Chris@16
|
63
|
Chris@16
|
64 template <typename Iterator, int N>
|
Chris@16
|
65 struct backward;
|
Chris@16
|
66
|
Chris@16
|
67 template <typename Iterator, int N>
|
Chris@16
|
68 struct next_backward
|
Chris@16
|
69 {
|
Chris@16
|
70 typedef typename
|
Chris@16
|
71 backward<
|
Chris@16
|
72 typename result_of::prior<Iterator>::type
|
Chris@16
|
73 , N+1
|
Chris@16
|
74 >::type
|
Chris@16
|
75 type;
|
Chris@16
|
76 };
|
Chris@16
|
77
|
Chris@16
|
78 template <typename Iterator, int N>
|
Chris@16
|
79 struct backward
|
Chris@16
|
80 {
|
Chris@16
|
81 typedef typename
|
Chris@16
|
82 mpl::eval_if_c<
|
Chris@16
|
83 (N == 0)
|
Chris@16
|
84 , mpl::identity<Iterator>
|
Chris@16
|
85 , next_backward<Iterator, N>
|
Chris@16
|
86 >::type
|
Chris@16
|
87 type;
|
Chris@16
|
88
|
Chris@101
|
89 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
Chris@16
|
90 static type const&
|
Chris@16
|
91 call(type const& i)
|
Chris@16
|
92 {
|
Chris@16
|
93 return i;
|
Chris@16
|
94 }
|
Chris@16
|
95
|
Chris@16
|
96 template <typename I>
|
Chris@101
|
97 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
Chris@16
|
98 static type
|
Chris@16
|
99 call(I const& i)
|
Chris@16
|
100 {
|
Chris@16
|
101 return call(fusion::prior(i));
|
Chris@16
|
102 }
|
Chris@16
|
103 };
|
Chris@16
|
104
|
Chris@16
|
105 }}}
|
Chris@16
|
106
|
Chris@16
|
107 #endif
|