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

Private GIT Repository
fe498acbaf3c834cf5d8170b8b537243ae54482c
[canny.git] / stc / exp / ml_stc_linux_make_v1.0 / include / boost / mpl / aux_ / full_lambda.hpp
1 \r
2 #if !defined(BOOST_PP_IS_ITERATING)\r
3 \r
4 ///// header body\r
5 \r
6 #ifndef BOOST_MPL_AUX_FULL_LAMBDA_HPP_INCLUDED\r
7 #define BOOST_MPL_AUX_FULL_LAMBDA_HPP_INCLUDED\r
8 \r
9 // Copyright Aleksey Gurtovoy 2001-2004\r
10 //\r
11 // Distributed under the Boost Software License, Version 1.0. \r
12 // (See accompanying file LICENSE_1_0.txt or copy at \r
13 // http://www.boost.org/LICENSE_1_0.txt)\r
14 //\r
15 // See http://www.boost.org/libs/mpl for documentation.\r
16 \r
17 // $Id: full_lambda.hpp 49267 2008-10-11 06:19:02Z agurtovoy $\r
18 // $Date: 2008-10-11 02:19:02 -0400 (Sat, 11 Oct 2008) $\r
19 // $Revision: 49267 $\r
20 \r
21 #if !defined(BOOST_MPL_PREPROCESSING_MODE)\r
22 #   include <boost/mpl/lambda_fwd.hpp>\r
23 #   include <boost/mpl/bind_fwd.hpp>\r
24 #   include <boost/mpl/protect.hpp>\r
25 #   include <boost/mpl/quote.hpp>\r
26 #   include <boost/mpl/arg.hpp>\r
27 #   include <boost/mpl/bool.hpp>\r
28 #   include <boost/mpl/int_fwd.hpp>\r
29 #   include <boost/mpl/aux_/template_arity.hpp>\r
30 #   include <boost/mpl/aux_/na_spec.hpp>\r
31 #   include <boost/mpl/aux_/config/ttp.hpp>\r
32 #   if defined(BOOST_MPL_CFG_EXTENDED_TEMPLATE_PARAMETERS_MATCHING)\r
33 #       include <boost/mpl/if.hpp>\r
34 #   endif\r
35 #endif\r
36 \r
37 #include <boost/mpl/aux_/lambda_arity_param.hpp>\r
38 #include <boost/mpl/aux_/config/use_preprocessed.hpp>\r
39 \r
40 #if !defined(BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS) \\r
41     && !defined(BOOST_MPL_PREPROCESSING_MODE)\r
42 \r
43 #   define BOOST_MPL_PREPROCESSED_HEADER full_lambda.hpp\r
44 #   include <boost/mpl/aux_/include_preprocessed.hpp>\r
45 \r
46 #else\r
47 \r
48 #   include <boost/mpl/limits/arity.hpp>\r
49 #   include <boost/mpl/aux_/preprocessor/default_params.hpp>\r
50 #   include <boost/mpl/aux_/preprocessor/params.hpp>\r
51 #   include <boost/mpl/aux_/preprocessor/enum.hpp>\r
52 #   include <boost/mpl/aux_/preprocessor/repeat.hpp>\r
53 #   include <boost/mpl/aux_/config/dmc_ambiguous_ctps.hpp>\r
54 \r
55 #   include <boost/preprocessor/iterate.hpp>\r
56 #   include <boost/preprocessor/comma_if.hpp>\r
57 #   include <boost/preprocessor/inc.hpp>\r
58 #   include <boost/preprocessor/cat.hpp>\r
59 \r
60 namespace boost { namespace mpl {\r
61 \r
62 // local macros, #undef-ined at the end of the header\r
63 #   define AUX778076_LAMBDA_PARAMS(i_, param) \\r
64     BOOST_MPL_PP_PARAMS(i_, param) \\r
65     /**/\r
66 \r
67 #   define AUX778076_BIND_PARAMS(param) \\r
68     BOOST_MPL_PP_PARAMS( \\r
69           BOOST_MPL_LIMIT_METAFUNCTION_ARITY \\r
70         , param \\r
71         ) \\r
72     /**/\r
73 \r
74 #   define AUX778076_BIND_N_PARAMS(i_, param) \\r
75     BOOST_PP_COMMA_IF(i_) \\r
76     BOOST_MPL_PP_PARAMS(i_, param) \\r
77     /**/\r
78 \r
79 #   define AUX778076_ARITY_PARAM(param) \\r
80     BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(param) \\r
81     /**/\r
82 \r
83 \r
84 #define n_ BOOST_MPL_LIMIT_METAFUNCTION_ARITY\r
85 namespace aux {\r
86 \r
87 template<\r
88       BOOST_MPL_PP_DEFAULT_PARAMS(n_,bool C,false)\r
89     >\r
90 struct lambda_or\r
91     : true_\r
92 {\r
93 };\r
94 \r
95 template<>\r
96 struct lambda_or< BOOST_MPL_PP_ENUM(n_,false) >\r
97     : false_\r
98 {\r
99 };\r
100 \r
101 } // namespace aux\r
102 #undef n_\r
103 \r
104 template<\r
105       typename T\r
106     , typename Tag\r
107     AUX778076_ARITY_PARAM(typename Arity)\r
108     >\r
109 struct lambda\r
110 {\r
111     typedef false_ is_le;\r
112     typedef T result_;\r
113     typedef T type;\r
114 };\r
115 \r
116 template<\r
117       typename T\r
118     >\r
119 struct is_lambda_expression\r
120     : lambda<T>::is_le\r
121 {\r
122 };\r
123 \r
124 \r
125 template< int N, typename Tag >\r
126 struct lambda< arg<N>,Tag AUX778076_ARITY_PARAM(int_<-1>) >\r
127 {\r
128     typedef true_ is_le;\r
129     typedef mpl::arg<N> result_; // qualified for the sake of MIPSpro 7.41\r
130     typedef mpl::protect<result_> type; \r
131 };\r
132 \r
133 \r
134 #define BOOST_PP_ITERATION_PARAMS_1 \\r
135     (3,(0, BOOST_MPL_LIMIT_METAFUNCTION_ARITY, <boost/mpl/aux_/full_lambda.hpp>))\r
136 #include BOOST_PP_ITERATE()\r
137 \r
138 /// special case for 'protect'\r
139 template< typename T, typename Tag >\r
140 struct lambda< mpl::protect<T>,Tag AUX778076_ARITY_PARAM(int_<1>) >\r
141 {\r
142     typedef false_ is_le;\r
143     typedef mpl::protect<T> result_;\r
144     typedef result_ type;\r
145 };\r
146 \r
147 /// specializations for the main 'bind' form\r
148 template<\r
149       typename F, AUX778076_BIND_PARAMS(typename T)\r
150     , typename Tag\r
151     >\r
152 struct lambda<\r
153           bind<F,AUX778076_BIND_PARAMS(T)>\r
154         , Tag\r
155         AUX778076_ARITY_PARAM(int_<BOOST_PP_INC(BOOST_MPL_LIMIT_METAFUNCTION_ARITY)>)\r
156         >\r
157 {\r
158     typedef false_ is_le;\r
159     typedef bind<F, AUX778076_BIND_PARAMS(T)> result_;\r
160     typedef result_ type;\r
161 };\r
162 \r
163 \r
164 #if defined(BOOST_MPL_CFG_EXTENDED_TEMPLATE_PARAMETERS_MATCHING)\r
165 \r
166 template<\r
167       typename F\r
168     , typename Tag1\r
169     , typename Tag2\r
170     , typename Arity\r
171     >\r
172 struct lambda<\r
173           lambda<F,Tag1,Arity>\r
174         , Tag2\r
175         , int_<3>\r
176         >\r
177 {\r
178     typedef lambda< F,Tag2 > l1;\r
179     typedef lambda< Tag1,Tag2 > l2;\r
180 \r
181     typedef typename l1::is_le is_le;\r
182     typedef bind1< quote1<aux::template_arity>, typename l1::result_ > arity_;\r
183     typedef lambda< typename if_<is_le,arity_,Arity>::type,Tag2 > l3;\r
184     \r
185     typedef aux::le_result3<is_le, Tag2, mpl::lambda, l1, l2, l3> le_result_;\r
186     typedef typename le_result_::result_ result_;\r
187     typedef typename le_result_::type type;\r
188 };\r
189 \r
190 #elif !defined(BOOST_MPL_CFG_DMC_AMBIGUOUS_CTPS)\r
191 \r
192 /// workaround for MWCW 8.3+/EDG < 303, leads to ambiguity on Digital Mars\r
193 template<\r
194       typename F, typename Tag1, typename Tag2\r
195     >\r
196 struct lambda<\r
197           lambda< F,Tag1 >\r
198         , Tag2\r
199         >\r
200 {\r
201     typedef lambda< F,Tag2 > l1;\r
202     typedef lambda< Tag1,Tag2 > l2;\r
203     \r
204     typedef typename l1::is_le is_le;\r
205     typedef aux::le_result2<is_le, Tag2, mpl::lambda, l1, l2> le_result_;\r
206     typedef typename le_result_::result_ result_;\r
207     typedef typename le_result_::type type;\r
208 };\r
209 \r
210 #endif\r
211 \r
212 #   undef AUX778076_ARITY_PARAM\r
213 #   undef AUX778076_BIND_N_PARAMS\r
214 #   undef AUX778076_BIND_PARAMS\r
215 #   undef AUX778076_LAMBDA_PARAMS\r
216 \r
217 #if !defined(BOOST_MPL_CFG_EXTENDED_TEMPLATE_PARAMETERS_MATCHING)\r
218 BOOST_MPL_AUX_NA_SPEC(2, lambda)\r
219 #else\r
220 BOOST_MPL_AUX_NA_SPEC2(2, 3, lambda)\r
221 #endif\r
222 \r
223 }}\r
224 \r
225 #endif // BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS\r
226 #endif // BOOST_MPL_AUX_FULL_LAMBDA_HPP_INCLUDED\r
227 \r
228 ///// iteration, depth == 1\r
229 \r
230 // For gcc 4.4 compatability, we must include the\r
231 // BOOST_PP_ITERATION_DEPTH test inside an #else clause.\r
232 #else // BOOST_PP_IS_ITERATING\r
233 #if BOOST_PP_ITERATION_DEPTH() == 1\r
234 #define i_ BOOST_PP_FRAME_ITERATION(1)\r
235 \r
236 #if i_ > 0\r
237 \r
238 namespace aux {\r
239 \r
240 #   define AUX778076_RESULT(unused, i_, T) \\r
241     BOOST_PP_COMMA_IF(i_) \\r
242     typename BOOST_PP_CAT(T, BOOST_PP_INC(i_))::result_ \\r
243     /**/\r
244 \r
245 #   define AUX778076_TYPE(unused, i_, T) \\r
246     BOOST_PP_COMMA_IF(i_) \\r
247     typename BOOST_PP_CAT(T, BOOST_PP_INC(i_))::type \\r
248     /**/\r
249 \r
250 template<\r
251       typename IsLE, typename Tag\r
252     , template< AUX778076_LAMBDA_PARAMS(i_, typename P) > class F\r
253     , AUX778076_LAMBDA_PARAMS(i_, typename L)\r
254     >\r
255 struct BOOST_PP_CAT(le_result,i_)\r
256 {\r
257     typedef F<\r
258           BOOST_MPL_PP_REPEAT(i_, AUX778076_TYPE, L)\r
259         > result_;\r
260     \r
261     typedef result_ type;\r
262 };\r
263 \r
264 template<\r
265       typename Tag\r
266     , template< AUX778076_LAMBDA_PARAMS(i_, typename P) > class F\r
267     , AUX778076_LAMBDA_PARAMS(i_, typename L)\r
268     >\r
269 struct BOOST_PP_CAT(le_result,i_)< true_,Tag,F,AUX778076_LAMBDA_PARAMS(i_, L) >\r
270 {\r
271     typedef BOOST_PP_CAT(bind,i_)<\r
272           BOOST_PP_CAT(quote,i_)<F,Tag>\r
273         , BOOST_MPL_PP_REPEAT(i_, AUX778076_RESULT, L)\r
274         > result_;\r
275 \r
276     typedef mpl::protect<result_> type;\r
277 };\r
278 \r
279 #   undef AUX778076_TYPE\r
280 #   undef AUX778076_RESULT\r
281 \r
282 } // namespace aux\r
283 \r
284 \r
285 #   define AUX778076_LAMBDA_TYPEDEF(unused, i_, T) \\r
286     typedef lambda< BOOST_PP_CAT(T, BOOST_PP_INC(i_)), Tag > \\r
287         BOOST_PP_CAT(l,BOOST_PP_INC(i_)); \\r
288 /**/\r
289 \r
290 #   define AUX778076_IS_LE_TYPEDEF(unused, i_, unused2) \\r
291     typedef typename BOOST_PP_CAT(l,BOOST_PP_INC(i_))::is_le \\r
292         BOOST_PP_CAT(is_le,BOOST_PP_INC(i_)); \\r
293 /**/\r
294 \r
295 #   define AUX778076_IS_LAMBDA_EXPR(unused, i_, unused2) \\r
296     BOOST_PP_COMMA_IF(i_) \\r
297     BOOST_PP_CAT(is_le,BOOST_PP_INC(i_))::value \\r
298 /**/\r
299 \r
300 template<\r
301       template< AUX778076_LAMBDA_PARAMS(i_, typename P) > class F\r
302     , AUX778076_LAMBDA_PARAMS(i_, typename T)\r
303     , typename Tag\r
304     >\r
305 struct lambda< \r
306           F<AUX778076_LAMBDA_PARAMS(i_, T)>\r
307         , Tag\r
308         AUX778076_ARITY_PARAM(int_<i_>)\r
309         >\r
310 {\r
311     BOOST_MPL_PP_REPEAT(i_, AUX778076_LAMBDA_TYPEDEF, T)\r
312     BOOST_MPL_PP_REPEAT(i_, AUX778076_IS_LE_TYPEDEF, unused)\r
313 \r
314     typedef typename aux::lambda_or<\r
315           BOOST_MPL_PP_REPEAT(i_, AUX778076_IS_LAMBDA_EXPR, unused)\r
316         >::type is_le;\r
317 \r
318     typedef aux::BOOST_PP_CAT(le_result,i_)<\r
319           is_le, Tag, F, AUX778076_LAMBDA_PARAMS(i_, l)\r
320         > le_result_;\r
321     \r
322     typedef typename le_result_::result_ result_;\r
323     typedef typename le_result_::type type;\r
324 };\r
325 \r
326 \r
327 #   undef AUX778076_IS_LAMBDA_EXPR\r
328 #   undef AUX778076_IS_LE_TYPEDEF\r
329 #   undef AUX778076_LAMBDA_TYPEDEF\r
330 \r
331 #endif // i_ > 0\r
332 \r
333 template<\r
334       typename F AUX778076_BIND_N_PARAMS(i_, typename T)\r
335     , typename Tag\r
336     >\r
337 struct lambda<\r
338           BOOST_PP_CAT(bind,i_)<F AUX778076_BIND_N_PARAMS(i_, T)>\r
339         , Tag\r
340         AUX778076_ARITY_PARAM(int_<BOOST_PP_INC(i_)>)\r
341         >\r
342 {\r
343     typedef false_ is_le;\r
344     typedef BOOST_PP_CAT(bind,i_)<\r
345           F\r
346         AUX778076_BIND_N_PARAMS(i_, T)\r
347         > result_;\r
348         \r
349     typedef result_ type;\r
350 };\r
351 \r
352 #undef i_\r
353 #endif // BOOST_PP_ITERATION_DEPTH()\r
354 #endif // BOOST_PP_IS_ITERATING\r