Fixes for VS 2008
[dyninst.git] / external / boost / mpl / aux_ / iter_fold_if_impl.hpp
1 \r
2 #ifndef BOOST_MPL_AUX_ITER_FOLD_IF_IMPL_HPP_INCLUDED\r
3 #define BOOST_MPL_AUX_ITER_FOLD_IF_IMPL_HPP_INCLUDED\r
4 \r
5 // Copyright Aleksey Gurtovoy 2001-2004\r
6 // Copyright David Abrahams 2001-2002\r
7 //\r
8 // Distributed under the Boost Software License, Version 1.0. \r
9 // (See accompanying file LICENSE_1_0.txt or copy at \r
10 // http://www.boost.org/LICENSE_1_0.txt)\r
11 //\r
12 // See http://www.boost.org/libs/mpl for documentation.\r
13 \r
14 // $Id: iter_fold_if_impl.hpp 49267 2008-10-11 06:19:02Z agurtovoy $\r
15 // $Date: 2008-10-11 02:19:02 -0400 (Sat, 11 Oct 2008) $\r
16 // $Revision: 49267 $\r
17 \r
18 #if !defined(BOOST_MPL_PREPROCESSING_MODE)\r
19 #   include <boost/mpl/identity.hpp>\r
20 #   include <boost/mpl/next.hpp>\r
21 #   include <boost/mpl/if.hpp>\r
22 #   include <boost/mpl/apply.hpp>\r
23 #   include <boost/mpl/aux_/value_wknd.hpp>\r
24 #endif\r
25 \r
26 #include <boost/mpl/aux_/config/use_preprocessed.hpp>\r
27 \r
28 #if !defined(BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS) \\r
29     && !defined(BOOST_MPL_PREPROCESSING_MODE)\r
30 \r
31 #   define BOOST_MPL_PREPROCESSED_HEADER iter_fold_if_impl.hpp\r
32 #   include <boost/mpl/aux_/include_preprocessed.hpp>\r
33 \r
34 #else\r
35 \r
36 #   include <boost/mpl/limits/unrolling.hpp>\r
37 #   include <boost/preprocessor/arithmetic/sub.hpp>\r
38 #   include <boost/preprocessor/repeat.hpp>\r
39 #   include <boost/preprocessor/inc.hpp>\r
40 #   include <boost/preprocessor/dec.hpp>\r
41 #   include <boost/preprocessor/cat.hpp>\r
42 \r
43 namespace boost { namespace mpl { namespace aux {\r
44 \r
45 template< typename Iterator, typename State >\r
46 struct iter_fold_if_null_step\r
47 {\r
48     typedef State state;\r
49     typedef Iterator iterator;\r
50 };\r
51 \r
52 template< bool >\r
53 struct iter_fold_if_step_impl\r
54 {\r
55     template<\r
56           typename Iterator\r
57         , typename State\r
58         , typename StateOp\r
59         , typename IteratorOp\r
60         >\r
61     struct result_\r
62     {\r
63         typedef typename apply2<StateOp,State,Iterator>::type state;\r
64         typedef typename IteratorOp::type iterator;\r
65     };\r
66 };\r
67 \r
68 template<>\r
69 struct iter_fold_if_step_impl<false>\r
70 {\r
71     template<\r
72           typename Iterator\r
73         , typename State\r
74         , typename StateOp\r
75         , typename IteratorOp\r
76         >\r
77     struct result_\r
78     {\r
79         typedef State state;\r
80         typedef Iterator iterator;\r
81     };\r
82 };\r
83 \r
84 // agurt, 25/jun/02: MSVC 6.5 workaround, had to get rid of inheritance \r
85 // here and in 'iter_fold_if_backward_step', because sometimes it interfered \r
86 // with the "early template instantiation bug" in _really_ ugly ways\r
87 template<\r
88       typename Iterator\r
89     , typename State\r
90     , typename ForwardOp\r
91     , typename Predicate\r
92     >\r
93 struct iter_fold_if_forward_step\r
94 {\r
95     typedef typename apply2<Predicate,State,Iterator>::type not_last;\r
96     typedef typename iter_fold_if_step_impl<\r
97           BOOST_MPL_AUX_MSVC_VALUE_WKND(not_last)::value\r
98         >::template result_< Iterator,State,ForwardOp,mpl::next<Iterator> > impl_;\r
99 \r
100     typedef typename impl_::state state;\r
101     typedef typename impl_::iterator iterator;\r
102 };\r
103 \r
104 template<\r
105       typename Iterator\r
106     , typename State\r
107     , typename BackwardOp\r
108     , typename Predicate\r
109     >\r
110 struct iter_fold_if_backward_step\r
111 {\r
112     typedef typename apply2<Predicate,State,Iterator>::type not_last;\r
113     typedef typename iter_fold_if_step_impl<\r
114           BOOST_MPL_AUX_MSVC_VALUE_WKND(not_last)::value\r
115         >::template result_< Iterator,State,BackwardOp,identity<Iterator> > impl_;\r
116 \r
117     typedef typename impl_::state state;\r
118     typedef typename impl_::iterator iterator;\r
119 };\r
120 \r
121 \r
122 // local macros, #undef-ined at the end of the header\r
123 \r
124 #   define AUX_ITER_FOLD_FORWARD_STEP(unused, i, unused2) \\r
125     typedef iter_fold_if_forward_step< \\r
126           typename BOOST_PP_CAT(forward_step,i)::iterator \\r
127         , typename BOOST_PP_CAT(forward_step,i)::state \\r
128         , ForwardOp \\r
129         , ForwardPredicate \\r
130         > BOOST_PP_CAT(forward_step, BOOST_PP_INC(i)); \\r
131     /**/\r
132 \r
133 #   define AUX_ITER_FOLD_BACKWARD_STEP_FUNC(i) \\r
134     typedef iter_fold_if_backward_step< \\r
135           typename BOOST_PP_CAT(forward_step,BOOST_PP_DEC(i))::iterator \\r
136         , typename BOOST_PP_CAT(backward_step,i)::state \\r
137         , BackwardOp \\r
138         , BackwardPredicate \\r
139         > BOOST_PP_CAT(backward_step,BOOST_PP_DEC(i)); \\r
140     /**/\r
141 \r
142 #   define AUX_ITER_FOLD_BACKWARD_STEP(unused, i, unused2) \\r
143     AUX_ITER_FOLD_BACKWARD_STEP_FUNC( \\r
144         BOOST_PP_SUB_D(1,BOOST_MPL_LIMIT_UNROLLING,i) \\r
145         ) \\r
146     /**/\r
147 \r
148 #   define AUX_LAST_FORWARD_STEP \\r
149     BOOST_PP_CAT(forward_step, BOOST_MPL_LIMIT_UNROLLING) \\r
150     /**/\r
151 \r
152 #   define AUX_LAST_BACKWARD_STEP \\r
153     BOOST_PP_CAT(backward_step, BOOST_MPL_LIMIT_UNROLLING) \\r
154     /**/\r
155 \r
156 template<\r
157       typename Iterator\r
158     , typename State\r
159     , typename ForwardOp\r
160     , typename ForwardPredicate\r
161     , typename BackwardOp\r
162     , typename BackwardPredicate\r
163     >\r
164 struct iter_fold_if_impl\r
165 {\r
166  private:\r
167     typedef iter_fold_if_null_step<Iterator,State> forward_step0;\r
168     BOOST_PP_REPEAT(\r
169           BOOST_MPL_LIMIT_UNROLLING\r
170         , AUX_ITER_FOLD_FORWARD_STEP\r
171         , unused\r
172         )\r
173     \r
174     typedef typename if_<\r
175           typename AUX_LAST_FORWARD_STEP::not_last\r
176         , iter_fold_if_impl<\r
177               typename AUX_LAST_FORWARD_STEP::iterator\r
178             , typename AUX_LAST_FORWARD_STEP::state\r
179             , ForwardOp\r
180             , ForwardPredicate\r
181             , BackwardOp\r
182             , BackwardPredicate\r
183             >\r
184         , iter_fold_if_null_step<\r
185               typename AUX_LAST_FORWARD_STEP::iterator\r
186             , typename AUX_LAST_FORWARD_STEP::state\r
187             >\r
188         >::type AUX_LAST_BACKWARD_STEP;\r
189 \r
190     BOOST_PP_REPEAT(\r
191           BOOST_MPL_LIMIT_UNROLLING\r
192         , AUX_ITER_FOLD_BACKWARD_STEP\r
193         , unused\r
194         )\r
195 \r
196  public:\r
197     typedef typename backward_step0::state state;\r
198     typedef typename AUX_LAST_BACKWARD_STEP::iterator iterator;\r
199 };\r
200 \r
201 #   undef AUX_LAST_BACKWARD_STEP\r
202 #   undef AUX_LAST_FORWARD_STEP\r
203 #   undef AUX_ITER_FOLD_BACKWARD_STEP\r
204 #   undef AUX_ITER_FOLD_BACKWARD_STEP_FUNC\r
205 #   undef AUX_ITER_FOLD_FORWARD_STEP\r
206 \r
207 }}}\r
208 \r
209 #endif // BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS\r
210 #endif // BOOST_MPL_AUX_ITER_FOLD_IF_IMPL_HPP_INCLUDED\r