2 #if !defined(BOOST_PP_IS_ITERATING)
6 #ifndef BOOST_MPL_AUX_FULL_LAMBDA_HPP_INCLUDED
7 #define BOOST_MPL_AUX_FULL_LAMBDA_HPP_INCLUDED
9 // Copyright Aleksey Gurtovoy 2001-2004
11 // Distributed under the Boost Software License, Version 1.0.
12 // (See accompanying file LICENSE_1_0.txt or copy at
13 // http://www.boost.org/LICENSE_1_0.txt)
15 // See http://www.boost.org/libs/mpl for documentation.
17 // $Source: /cvsroot/boost/boost/boost/mpl/aux_/full_lambda.hpp,v $
18 // $Date: 2004/09/04 01:10:19 $
21 #if !defined(BOOST_MPL_PREPROCESSING_MODE)
22 # include <boost/mpl/lambda_fwd.hpp>
23 # include <boost/mpl/bind_fwd.hpp>
24 # include <boost/mpl/protect.hpp>
25 # include <boost/mpl/quote.hpp>
26 # include <boost/mpl/arg.hpp>
27 # include <boost/mpl/bool.hpp>
28 # include <boost/mpl/int_fwd.hpp>
29 # include <boost/mpl/aux_/template_arity.hpp>
30 # include <boost/mpl/aux_/na_spec.hpp>
31 # include <boost/mpl/aux_/config/ttp.hpp>
32 # if defined(BOOST_MPL_CFG_EXTENDED_TEMPLATE_PARAMETERS_MATCHING)
33 # include <boost/mpl/if.hpp>
37 #include <boost/mpl/aux_/lambda_arity_param.hpp>
38 #include <boost/mpl/aux_/config/use_preprocessed.hpp>
40 #if !defined(BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS) \
41 && !defined(BOOST_MPL_PREPROCESSING_MODE)
43 # define BOOST_MPL_PREPROCESSED_HEADER full_lambda.hpp
44 # include <boost/mpl/aux_/include_preprocessed.hpp>
48 # include <boost/mpl/limits/arity.hpp>
49 # include <boost/mpl/aux_/preprocessor/default_params.hpp>
50 # include <boost/mpl/aux_/preprocessor/params.hpp>
51 # include <boost/mpl/aux_/preprocessor/enum.hpp>
52 # include <boost/mpl/aux_/preprocessor/repeat.hpp>
53 # include <boost/mpl/aux_/config/dmc_ambiguous_ctps.hpp>
55 # include <boost/preprocessor/iterate.hpp>
56 # include <boost/preprocessor/comma_if.hpp>
57 # include <boost/preprocessor/inc.hpp>
58 # include <boost/preprocessor/cat.hpp>
60 namespace boost { namespace mpl {
62 // local macros, #undef-ined at the end of the header
63 # define AUX778076_LAMBDA_PARAMS(i_, param) \
64 BOOST_MPL_PP_PARAMS(i_, param) \
67 # define AUX778076_BIND_PARAMS(param) \
68 BOOST_MPL_PP_PARAMS( \
69 BOOST_MPL_LIMIT_METAFUNCTION_ARITY \
74 # define AUX778076_BIND_N_PARAMS(i_, param) \
75 BOOST_PP_COMMA_IF(i_) \
76 BOOST_MPL_PP_PARAMS(i_, param) \
79 # define AUX778076_ARITY_PARAM(param) \
80 BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(param) \
84 #define n_ BOOST_MPL_LIMIT_METAFUNCTION_ARITY
88 BOOST_MPL_PP_DEFAULT_PARAMS(n_,bool C,false)
96 struct lambda_or< BOOST_MPL_PP_ENUM(n_,false) >
107 AUX778076_ARITY_PARAM(typename Arity)
111 typedef false_ is_le;
119 struct is_lambda_expression
125 template< int N, typename Tag >
126 struct lambda< arg<N>,Tag AUX778076_ARITY_PARAM(int_<-1>) >
129 typedef mpl::arg<N> result_; // qualified for the sake of MIPSpro 7.41
130 typedef mpl::protect<result_> type;
134 #define BOOST_PP_ITERATION_PARAMS_1 \
135 (3,(0, BOOST_MPL_LIMIT_METAFUNCTION_ARITY, <boost/mpl/aux_/full_lambda.hpp>))
136 #include BOOST_PP_ITERATE()
138 /// special case for 'protect'
139 template< typename T, typename Tag >
140 struct lambda< mpl::protect<T>,Tag AUX778076_ARITY_PARAM(int_<1>) >
142 typedef false_ is_le;
143 typedef mpl::protect<T> result_;
144 typedef result_ type;
147 /// specializations for the main 'bind' form
149 typename F, AUX778076_BIND_PARAMS(typename T)
153 bind<F,AUX778076_BIND_PARAMS(T)>
155 AUX778076_ARITY_PARAM(int_<BOOST_PP_INC(BOOST_MPL_LIMIT_METAFUNCTION_ARITY)>)
158 typedef false_ is_le;
159 typedef bind<F, AUX778076_BIND_PARAMS(T)> result_;
160 typedef result_ type;
164 #if defined(BOOST_MPL_CFG_EXTENDED_TEMPLATE_PARAMETERS_MATCHING)
178 typedef lambda< F,Tag2 > l1;
179 typedef lambda< Tag1,Tag2 > l2;
181 typedef typename l1::is_le is_le;
182 typedef bind1< quote1<aux::template_arity>, typename l1::result_ > arity_;
183 typedef lambda< typename if_<is_le,arity_,Arity>::type,Tag2 > l3;
185 typedef aux::le_result3<is_le, Tag2, mpl::lambda, l1, l2, l3> le_result_;
186 typedef typename le_result_::result_ result_;
187 typedef typename le_result_::type type;
190 #elif !defined(BOOST_MPL_CFG_DMC_AMBIGUOUS_CTPS)
192 /// workaround for MWCW 8.3+/EDG < 303, leads to ambiguity on Digital Mars
194 typename F, typename Tag1, typename Tag2
201 typedef lambda< F,Tag2 > l1;
202 typedef lambda< Tag1,Tag2 > l2;
204 typedef typename l1::is_le is_le;
205 typedef aux::le_result2<is_le, Tag2, mpl::lambda, l1, l2> le_result_;
206 typedef typename le_result_::result_ result_;
207 typedef typename le_result_::type type;
212 # undef AUX778076_ARITY_PARAM
213 # undef AUX778076_BIND_N_PARAMS
214 # undef AUX778076_BIND_PARAMS
215 # undef AUX778076_LAMBDA_PARAMS
217 #if !defined(BOOST_MPL_CFG_EXTENDED_TEMPLATE_PARAMETERS_MATCHING)
218 BOOST_MPL_AUX_NA_SPEC(2, lambda)
220 BOOST_MPL_AUX_NA_SPEC2(2, 3, lambda)
225 #endif // BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
226 #endif // BOOST_MPL_AUX_FULL_LAMBDA_HPP_INCLUDED
228 ///// iteration, depth == 1
230 #elif BOOST_PP_ITERATION_DEPTH() == 1
231 #define i_ BOOST_PP_FRAME_ITERATION(1)
237 # define AUX778076_RESULT(unused, i_, T) \
238 BOOST_PP_COMMA_IF(i_) \
239 typename BOOST_PP_CAT(T, BOOST_PP_INC(i_))::result_ \
242 # define AUX778076_TYPE(unused, i_, T) \
243 BOOST_PP_COMMA_IF(i_) \
244 typename BOOST_PP_CAT(T, BOOST_PP_INC(i_))::type \
248 typename IsLE, typename Tag
249 , template< AUX778076_LAMBDA_PARAMS(i_, typename P) > class F
250 , AUX778076_LAMBDA_PARAMS(i_, typename L)
252 struct BOOST_PP_CAT(le_result,i_)
255 BOOST_MPL_PP_REPEAT(i_, AUX778076_TYPE, L)
258 typedef result_ type;
263 , template< AUX778076_LAMBDA_PARAMS(i_, typename P) > class F
264 , AUX778076_LAMBDA_PARAMS(i_, typename L)
266 struct BOOST_PP_CAT(le_result,i_)< true_,Tag,F,AUX778076_LAMBDA_PARAMS(i_, L) >
268 typedef BOOST_PP_CAT(bind,i_)<
269 BOOST_PP_CAT(quote,i_)<F,Tag>
270 , BOOST_MPL_PP_REPEAT(i_, AUX778076_RESULT, L)
273 typedef mpl::protect<result_> type;
276 # undef AUX778076_TYPE
277 # undef AUX778076_RESULT
282 # define AUX778076_LAMBDA_TYPEDEF(unused, i_, T) \
283 typedef lambda< BOOST_PP_CAT(T, BOOST_PP_INC(i_)), Tag > \
284 BOOST_PP_CAT(l,BOOST_PP_INC(i_)); \
287 # define AUX778076_IS_LE_TYPEDEF(unused, i_, unused2) \
288 typedef typename BOOST_PP_CAT(l,BOOST_PP_INC(i_))::is_le \
289 BOOST_PP_CAT(is_le,BOOST_PP_INC(i_)); \
292 # define AUX778076_IS_LAMBDA_EXPR(unused, i_, unused2) \
293 BOOST_PP_COMMA_IF(i_) \
294 BOOST_PP_CAT(is_le,BOOST_PP_INC(i_))::value \
298 template< AUX778076_LAMBDA_PARAMS(i_, typename P) > class F
299 , AUX778076_LAMBDA_PARAMS(i_, typename T)
303 F<AUX778076_LAMBDA_PARAMS(i_, T)>
305 AUX778076_ARITY_PARAM(int_<i_>)
308 BOOST_MPL_PP_REPEAT(i_, AUX778076_LAMBDA_TYPEDEF, T)
309 BOOST_MPL_PP_REPEAT(i_, AUX778076_IS_LE_TYPEDEF, unused)
311 typedef typename aux::lambda_or<
312 BOOST_MPL_PP_REPEAT(i_, AUX778076_IS_LAMBDA_EXPR, unused)
315 typedef aux::BOOST_PP_CAT(le_result,i_)<
316 is_le, Tag, F, AUX778076_LAMBDA_PARAMS(i_, l)
319 typedef typename le_result_::result_ result_;
320 typedef typename le_result_::type type;
324 # undef AUX778076_IS_LAMBDA_EXPR
325 # undef AUX778076_IS_LE_TYPEDEF
326 # undef AUX778076_LAMBDA_TYPEDEF
331 typename F AUX778076_BIND_N_PARAMS(i_, typename T)
335 BOOST_PP_CAT(bind,i_)<F AUX778076_BIND_N_PARAMS(i_, T)>
337 AUX778076_ARITY_PARAM(int_<BOOST_PP_INC(i_)>)
340 typedef false_ is_le;
341 typedef BOOST_PP_CAT(bind,i_)<
343 AUX778076_BIND_N_PARAMS(i_, T)
346 typedef result_ type;
350 #endif // BOOST_PP_IS_ITERATING