2 #if !defined(BOOST_PP_IS_ITERATING)
\r
6 #ifndef BOOST_MPL_AUX_FULL_LAMBDA_HPP_INCLUDED
\r
7 #define BOOST_MPL_AUX_FULL_LAMBDA_HPP_INCLUDED
\r
9 // Copyright Aleksey Gurtovoy 2001-2004
\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
15 // See http://www.boost.org/libs/mpl for documentation.
\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
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
37 #include <boost/mpl/aux_/lambda_arity_param.hpp>
\r
38 #include <boost/mpl/aux_/config/use_preprocessed.hpp>
\r
40 #if !defined(BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS) \
\r
41 && !defined(BOOST_MPL_PREPROCESSING_MODE)
\r
43 # define BOOST_MPL_PREPROCESSED_HEADER full_lambda.hpp
\r
44 # include <boost/mpl/aux_/include_preprocessed.hpp>
\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
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
60 namespace boost { namespace mpl {
\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
67 # define AUX778076_BIND_PARAMS(param) \
\r
68 BOOST_MPL_PP_PARAMS( \
\r
69 BOOST_MPL_LIMIT_METAFUNCTION_ARITY \
\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
79 # define AUX778076_ARITY_PARAM(param) \
\r
80 BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(param) \
\r
84 #define n_ BOOST_MPL_LIMIT_METAFUNCTION_ARITY
\r
88 BOOST_MPL_PP_DEFAULT_PARAMS(n_,bool C,false)
\r
96 struct lambda_or< BOOST_MPL_PP_ENUM(n_,false) >
\r
107 AUX778076_ARITY_PARAM(typename Arity)
\r
111 typedef false_ is_le;
\r
119 struct is_lambda_expression
\r
125 template< int N, typename Tag >
\r
126 struct lambda< arg<N>,Tag AUX778076_ARITY_PARAM(int_<-1>) >
\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
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
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
142 typedef false_ is_le;
\r
143 typedef mpl::protect<T> result_;
\r
144 typedef result_ type;
\r
147 /// specializations for the main 'bind' form
\r
149 typename F, AUX778076_BIND_PARAMS(typename T)
\r
153 bind<F,AUX778076_BIND_PARAMS(T)>
\r
155 AUX778076_ARITY_PARAM(int_<BOOST_PP_INC(BOOST_MPL_LIMIT_METAFUNCTION_ARITY)>)
\r
158 typedef false_ is_le;
\r
159 typedef bind<F, AUX778076_BIND_PARAMS(T)> result_;
\r
160 typedef result_ type;
\r
164 #if defined(BOOST_MPL_CFG_EXTENDED_TEMPLATE_PARAMETERS_MATCHING)
\r
173 lambda<F,Tag1,Arity>
\r
178 typedef lambda< F,Tag2 > l1;
\r
179 typedef lambda< Tag1,Tag2 > l2;
\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
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
190 #elif !defined(BOOST_MPL_CFG_DMC_AMBIGUOUS_CTPS)
\r
192 /// workaround for MWCW 8.3+/EDG < 303, leads to ambiguity on Digital Mars
\r
194 typename F, typename Tag1, typename Tag2
\r
201 typedef lambda< F,Tag2 > l1;
\r
202 typedef lambda< Tag1,Tag2 > l2;
\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
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
217 #if !defined(BOOST_MPL_CFG_EXTENDED_TEMPLATE_PARAMETERS_MATCHING)
\r
218 BOOST_MPL_AUX_NA_SPEC(2, lambda)
\r
220 BOOST_MPL_AUX_NA_SPEC2(2, 3, lambda)
\r
225 #endif // BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
\r
226 #endif // BOOST_MPL_AUX_FULL_LAMBDA_HPP_INCLUDED
\r
228 ///// iteration, depth == 1
\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
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
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
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
255 struct BOOST_PP_CAT(le_result,i_)
\r
258 BOOST_MPL_PP_REPEAT(i_, AUX778076_TYPE, L)
\r
261 typedef result_ type;
\r
266 , template< AUX778076_LAMBDA_PARAMS(i_, typename P) > class F
\r
267 , AUX778076_LAMBDA_PARAMS(i_, typename L)
\r
269 struct BOOST_PP_CAT(le_result,i_)< true_,Tag,F,AUX778076_LAMBDA_PARAMS(i_, L) >
\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
276 typedef mpl::protect<result_> type;
\r
279 # undef AUX778076_TYPE
\r
280 # undef AUX778076_RESULT
\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
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
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
301 template< AUX778076_LAMBDA_PARAMS(i_, typename P) > class F
\r
302 , AUX778076_LAMBDA_PARAMS(i_, typename T)
\r
306 F<AUX778076_LAMBDA_PARAMS(i_, T)>
\r
308 AUX778076_ARITY_PARAM(int_<i_>)
\r
311 BOOST_MPL_PP_REPEAT(i_, AUX778076_LAMBDA_TYPEDEF, T)
\r
312 BOOST_MPL_PP_REPEAT(i_, AUX778076_IS_LE_TYPEDEF, unused)
\r
314 typedef typename aux::lambda_or<
\r
315 BOOST_MPL_PP_REPEAT(i_, AUX778076_IS_LAMBDA_EXPR, unused)
\r
318 typedef aux::BOOST_PP_CAT(le_result,i_)<
\r
319 is_le, Tag, F, AUX778076_LAMBDA_PARAMS(i_, l)
\r
322 typedef typename le_result_::result_ result_;
\r
323 typedef typename le_result_::type type;
\r
327 # undef AUX778076_IS_LAMBDA_EXPR
\r
328 # undef AUX778076_IS_LE_TYPEDEF
\r
329 # undef AUX778076_LAMBDA_TYPEDEF
\r
334 typename F AUX778076_BIND_N_PARAMS(i_, typename T)
\r
338 BOOST_PP_CAT(bind,i_)<F AUX778076_BIND_N_PARAMS(i_, T)>
\r
340 AUX778076_ARITY_PARAM(int_<BOOST_PP_INC(i_)>)
\r
343 typedef false_ is_le;
\r
344 typedef BOOST_PP_CAT(bind,i_)<
\r
346 AUX778076_BIND_N_PARAMS(i_, T)
\r
349 typedef result_ type;
\r
353 #endif // BOOST_PP_ITERATION_DEPTH()
\r
354 #endif // BOOST_PP_IS_ITERATING
\r