]> AND Private Git Repository - canny.git/blob - stc/exp/ml_stc_linux_make_v1.0/include/boost/mpl/aux_/fold_impl_body.hpp
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
28ea74945ce38e00f6e658ca081795f0dc2633c9
[canny.git] / stc / exp / ml_stc_linux_make_v1.0 / include / boost / mpl / aux_ / fold_impl_body.hpp
1 \r
2 // NO INCLUDE GUARDS, THE HEADER IS INTENDED FOR MULTIPLE INCLUSION\r
3 \r
4 #if !defined(BOOST_PP_IS_ITERATING)\r
5 \r
6 // Copyright Aleksey Gurtovoy 2000-2004\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: fold_impl_body.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 #   include <boost/mpl/limits/unrolling.hpp>\r
19 #   include <boost/mpl/aux_/preprocessor/repeat.hpp>\r
20 #   include <boost/mpl/aux_/config/workaround.hpp>\r
21 #   include <boost/mpl/aux_/config/ctps.hpp>\r
22 #   include <boost/mpl/aux_/nttp_decl.hpp>\r
23 #   include <boost/mpl/aux_/config/eti.hpp>\r
24 \r
25 #   include <boost/preprocessor/iterate.hpp>\r
26 #   include <boost/preprocessor/dec.hpp>\r
27 #   include <boost/preprocessor/cat.hpp>\r
28 \r
29 // local macros, #undef-ined at the end of the header\r
30 \r
31 #   define AUX778076_ITER_FOLD_STEP(unused, i, unused2) \\r
32     typedef typename apply2< \\r
33           ForwardOp \\r
34         , BOOST_PP_CAT(state,i) \\r
35         , AUX778076_FOLD_IMPL_OP(BOOST_PP_CAT(iter,i)) \\r
36         >::type BOOST_PP_CAT(state,BOOST_PP_INC(i)); \\r
37     typedef typename mpl::next<BOOST_PP_CAT(iter,i)>::type \\r
38         BOOST_PP_CAT(iter,BOOST_PP_INC(i)); \\r
39     /**/\r
40 \r
41 #   define AUX778076_FOLD_IMPL_NAME \\r
42     BOOST_PP_CAT(AUX778076_FOLD_IMPL_NAME_PREFIX,_impl) \\r
43     /**/\r
44 \r
45 #   define AUX778076_FOLD_CHUNK_NAME \\r
46     BOOST_PP_CAT(AUX778076_FOLD_IMPL_NAME_PREFIX,_chunk) \\r
47     /**/\r
48 \r
49 namespace boost { namespace mpl { namespace aux {\r
50 \r
51 /// forward declaration\r
52 template<\r
53       BOOST_MPL_AUX_NTTP_DECL(int, N)\r
54     , typename First\r
55     , typename Last\r
56     , typename State\r
57     , typename ForwardOp\r
58     > \r
59 struct AUX778076_FOLD_IMPL_NAME;\r
60 \r
61 #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)\r
62 \r
63 #   if !BOOST_WORKAROUND(__BORLANDC__, < 0x600)\r
64 \r
65 #   define BOOST_PP_ITERATION_PARAMS_1 \\r
66     (3,(0, BOOST_MPL_LIMIT_UNROLLING, <boost/mpl/aux_/fold_impl_body.hpp>))\r
67 #   include BOOST_PP_ITERATE()\r
68 \r
69 // implementation for N that exceeds BOOST_MPL_LIMIT_UNROLLING\r
70 template<\r
71       BOOST_MPL_AUX_NTTP_DECL(int, N)\r
72     , typename First\r
73     , typename Last\r
74     , typename State\r
75     , typename ForwardOp\r
76     > \r
77 struct AUX778076_FOLD_IMPL_NAME\r
78 {\r
79     typedef AUX778076_FOLD_IMPL_NAME<\r
80           BOOST_MPL_LIMIT_UNROLLING\r
81         , First\r
82         , Last\r
83         , State\r
84         , ForwardOp\r
85         > chunk_;\r
86 \r
87     typedef AUX778076_FOLD_IMPL_NAME<\r
88           ( (N - BOOST_MPL_LIMIT_UNROLLING) < 0 ? 0 : N - BOOST_MPL_LIMIT_UNROLLING )\r
89         , typename chunk_::iterator\r
90         , Last\r
91         , typename chunk_::state\r
92         , ForwardOp\r
93         > res_;\r
94         \r
95     typedef typename res_::state state;\r
96     typedef typename res_::iterator iterator;\r
97 };\r
98 \r
99 // fallback implementation for sequences of unknown size\r
100 template<\r
101       typename First\r
102     , typename Last\r
103     , typename State\r
104     , typename ForwardOp\r
105     > \r
106 struct AUX778076_FOLD_IMPL_NAME<-1,First,Last,State,ForwardOp>\r
107     : AUX778076_FOLD_IMPL_NAME<\r
108           -1\r
109         , typename mpl::next<First>::type\r
110         , Last\r
111         , typename apply2<ForwardOp,State,AUX778076_FOLD_IMPL_OP(First)>::type\r
112         , ForwardOp\r
113         >\r
114 {\r
115 };\r
116 \r
117 template<\r
118       typename Last\r
119     , typename State\r
120     , typename ForwardOp\r
121     > \r
122 struct AUX778076_FOLD_IMPL_NAME<-1,Last,Last,State,ForwardOp>\r
123 {\r
124     typedef State state;\r
125     typedef Last iterator;\r
126 };\r
127 \r
128 #   else // BOOST_WORKAROUND(__BORLANDC__, < 0x600)\r
129 \r
130 // Borland have some serious problems with the unrolled version, so\r
131 // we always use a basic implementation\r
132 template<\r
133       BOOST_MPL_AUX_NTTP_DECL(int, N)\r
134     , typename First\r
135     , typename Last\r
136     , typename State\r
137     , typename ForwardOp\r
138     > \r
139 struct AUX778076_FOLD_IMPL_NAME\r
140 {\r
141     typedef AUX778076_FOLD_IMPL_NAME<\r
142           -1\r
143         , typename mpl::next<First>::type\r
144         , Last\r
145         , typename apply2<ForwardOp,State,AUX778076_FOLD_IMPL_OP(First)>::type\r
146         , ForwardOp\r
147         > res_;\r
148 \r
149     typedef typename res_::state state;\r
150     typedef typename res_::iterator iterator;\r
151     typedef state type;\r
152 };\r
153 \r
154 template<\r
155       BOOST_MPL_AUX_NTTP_DECL(int, N)\r
156      , typename Last\r
157     , typename State\r
158     , typename ForwardOp\r
159     > \r
160 struct AUX778076_FOLD_IMPL_NAME<N,Last,Last,State,ForwardOp >\r
161 {\r
162     typedef State state;\r
163     typedef Last iterator;\r
164     typedef state type;\r
165 };\r
166 \r
167 #   endif // BOOST_WORKAROUND(__BORLANDC__, < 0x600)\r
168  \r
169 #else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION\r
170 \r
171 template< BOOST_MPL_AUX_NTTP_DECL(int, N) >\r
172 struct AUX778076_FOLD_CHUNK_NAME;\r
173 \r
174 #   define BOOST_PP_ITERATION_PARAMS_1 \\r
175     (3,(0, BOOST_MPL_LIMIT_UNROLLING, <boost/mpl/aux_/fold_impl_body.hpp>))\r
176 #   include BOOST_PP_ITERATE()\r
177 \r
178 // implementation for N that exceeds BOOST_MPL_LIMIT_UNROLLING\r
179 template< BOOST_MPL_AUX_NTTP_DECL(int, N) > \r
180 struct AUX778076_FOLD_CHUNK_NAME\r
181 {\r
182     template<\r
183           typename First\r
184         , typename Last\r
185         , typename State\r
186         , typename ForwardOp\r
187         > \r
188     struct result_\r
189     {\r
190         typedef AUX778076_FOLD_IMPL_NAME<\r
191               BOOST_MPL_LIMIT_UNROLLING\r
192             , First\r
193             , Last\r
194             , State\r
195             , ForwardOp\r
196             > chunk_;\r
197 \r
198         typedef AUX778076_FOLD_IMPL_NAME<\r
199               ( (N - BOOST_MPL_LIMIT_UNROLLING) < 0 ? 0 : N - BOOST_MPL_LIMIT_UNROLLING )\r
200             , typename chunk_::iterator\r
201             , Last\r
202             , typename chunk_::state\r
203             , ForwardOp\r
204             > res_;\r
205 \r
206         typedef typename res_::state state;\r
207         typedef typename res_::iterator iterator;\r
208     };\r
209 };\r
210 \r
211 // fallback implementation for sequences of unknown size\r
212 template<\r
213       typename First\r
214     , typename Last\r
215     , typename State\r
216     , typename ForwardOp\r
217     > \r
218 struct BOOST_PP_CAT(AUX778076_FOLD_IMPL_NAME_PREFIX,_step);\r
219 \r
220 template<\r
221       typename Last\r
222     , typename State\r
223     >\r
224 struct BOOST_PP_CAT(AUX778076_FOLD_IMPL_NAME_PREFIX,_null_step)\r
225 {\r
226     typedef Last iterator;\r
227     typedef State state;\r
228 };\r
229 \r
230 template<> \r
231 struct AUX778076_FOLD_CHUNK_NAME<-1>\r
232 {\r
233     template<\r
234           typename First\r
235         , typename Last\r
236         , typename State\r
237         , typename ForwardOp\r
238         > \r
239     struct result_\r
240     {\r
241         typedef typename if_<\r
242               typename is_same<First,Last>::type\r
243             , BOOST_PP_CAT(AUX778076_FOLD_IMPL_NAME_PREFIX,_null_step)<Last,State>\r
244             , BOOST_PP_CAT(AUX778076_FOLD_IMPL_NAME_PREFIX,_step)<First,Last,State,ForwardOp>\r
245             >::type res_;\r
246 \r
247         typedef typename res_::state state;\r
248         typedef typename res_::iterator iterator;\r
249     };\r
250 \r
251 #if defined(BOOST_MPL_CFG_MSVC_60_ETI_BUG)\r
252     /// ETI workaround\r
253     template<> struct result_<int,int,int,int>\r
254     {\r
255         typedef int state;\r
256         typedef int iterator;\r
257     };\r
258 #endif\r
259 };\r
260 \r
261 template<\r
262       typename First\r
263     , typename Last\r
264     , typename State\r
265     , typename ForwardOp\r
266     > \r
267 struct BOOST_PP_CAT(AUX778076_FOLD_IMPL_NAME_PREFIX,_step)\r
268 {\r
269     // can't inherit here - it breaks MSVC 7.0\r
270     typedef AUX778076_FOLD_CHUNK_NAME<-1>::template result_<\r
271           typename mpl::next<First>::type\r
272         , Last\r
273         , typename apply2<ForwardOp,State,AUX778076_FOLD_IMPL_OP(First)>::type\r
274         , ForwardOp\r
275         > chunk_;\r
276 \r
277     typedef typename chunk_::state state;\r
278     typedef typename chunk_::iterator iterator;\r
279 };\r
280 \r
281 template<\r
282       BOOST_MPL_AUX_NTTP_DECL(int, N)\r
283     , typename First\r
284     , typename Last\r
285     , typename State\r
286     , typename ForwardOp\r
287     > \r
288 struct AUX778076_FOLD_IMPL_NAME\r
289     : AUX778076_FOLD_CHUNK_NAME<N>\r
290         ::template result_<First,Last,State,ForwardOp>\r
291 {\r
292 };\r
293 \r
294 #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION\r
295 \r
296 }}}\r
297 \r
298 #   undef AUX778076_FOLD_IMPL_NAME\r
299 #   undef AUX778076_FOLD_CHUNK_NAME\r
300 #   undef AUX778076_ITER_FOLD_STEP\r
301 \r
302 #undef AUX778076_FOLD_IMPL_OP\r
303 #undef AUX778076_FOLD_IMPL_NAME_PREFIX\r
304 \r
305 ///// iteration\r
306 \r
307 #else\r
308 \r
309 #   define n_ BOOST_PP_FRAME_ITERATION(1)\r
310 \r
311 #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)\r
312 \r
313 template<\r
314       typename First\r
315     , typename Last\r
316     , typename State\r
317     , typename ForwardOp\r
318     >\r
319 struct AUX778076_FOLD_IMPL_NAME<n_,First,Last,State,ForwardOp>\r
320 {\r
321     typedef First iter0;\r
322     typedef State state0;\r
323 \r
324     BOOST_MPL_PP_REPEAT(n_, AUX778076_ITER_FOLD_STEP, unused)\r
325 \r
326     typedef BOOST_PP_CAT(state,n_) state;\r
327     typedef BOOST_PP_CAT(iter,n_) iterator;\r
328 };\r
329 \r
330 #else\r
331 \r
332 template<> struct AUX778076_FOLD_CHUNK_NAME<n_>\r
333 {\r
334     template<\r
335           typename First\r
336         , typename Last\r
337         , typename State\r
338         , typename ForwardOp\r
339         >\r
340     struct result_\r
341     {\r
342         typedef First iter0;\r
343         typedef State state0;\r
344 \r
345         BOOST_MPL_PP_REPEAT(n_, AUX778076_ITER_FOLD_STEP, unused)\r
346 \r
347         typedef BOOST_PP_CAT(state,n_) state;\r
348         typedef BOOST_PP_CAT(iter,n_) iterator;\r
349     };\r
350 \r
351 #if defined(BOOST_MPL_CFG_MSVC_60_ETI_BUG)\r
352     /// ETI workaround\r
353     template<> struct result_<int,int,int,int>\r
354     {\r
355         typedef int state;\r
356         typedef int iterator;\r
357     };\r
358 #endif\r
359 };\r
360 \r
361 #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION\r
362 \r
363 #   undef n_\r
364 \r
365 #endif // BOOST_PP_IS_ITERATING\r