2 #if !defined(BOOST_PP_IS_ITERATING)
6 #ifndef BOOST_MPL_APPLY_HPP_INCLUDED
7 #define BOOST_MPL_APPLY_HPP_INCLUDED
9 // Copyright Aleksey Gurtovoy 2000-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 // $Id: apply.hpp 49267 2008-10-11 06:19:02Z agurtovoy $
18 // $Date: 2008-10-11 02:19:02 -0400 (Sat, 11 Oct 2008) $
21 #if !defined(BOOST_MPL_PREPROCESSING_MODE)
22 # include <boost/mpl/apply_fwd.hpp>
23 # include <boost/mpl/apply_wrap.hpp>
24 # include <boost/mpl/placeholders.hpp>
25 # include <boost/mpl/lambda.hpp>
26 # include <boost/mpl/aux_/na.hpp>
27 # include <boost/mpl/aux_/lambda_support.hpp>
30 #include <boost/mpl/aux_/config/use_preprocessed.hpp>
32 #if !defined(BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS) \
33 && !defined(BOOST_MPL_PREPROCESSING_MODE)
35 # define BOOST_MPL_PREPROCESSED_HEADER apply.hpp
36 # include <boost/mpl/aux_/include_preprocessed.hpp>
40 # include <boost/mpl/limits/arity.hpp>
41 # include <boost/mpl/aux_/preprocessor/params.hpp>
42 # include <boost/mpl/aux_/preprocessor/default_params.hpp>
43 # include <boost/mpl/aux_/preprocessor/partial_spec_params.hpp>
44 # include <boost/mpl/aux_/preprocessor/enum.hpp>
45 # include <boost/mpl/aux_/config/lambda.hpp>
46 # include <boost/mpl/aux_/config/dtp.hpp>
47 # include <boost/mpl/aux_/nttp_decl.hpp>
48 # include <boost/mpl/aux_/config/eti.hpp>
49 # include <boost/mpl/aux_/config/msvc.hpp>
50 # include <boost/mpl/aux_/config/workaround.hpp>
52 # include <boost/preprocessor/comma_if.hpp>
53 # include <boost/preprocessor/inc.hpp>
54 # include <boost/preprocessor/iterate.hpp>
55 # include <boost/preprocessor/cat.hpp>
57 namespace boost { namespace mpl {
59 // local macros, #undef-ined at the end of the header
60 # define AUX778076_APPLY_PARAMS(param) \
61 BOOST_MPL_PP_PARAMS( \
62 BOOST_MPL_LIMIT_METAFUNCTION_ARITY \
67 # define AUX778076_APPLY_DEF_PARAMS(param, value) \
68 BOOST_MPL_PP_DEFAULT_PARAMS( \
69 BOOST_MPL_LIMIT_METAFUNCTION_ARITY \
75 # define AUX778076_APPLY_N_PARAMS(n, param) \
76 BOOST_MPL_PP_PARAMS(n, param) \
79 # define AUX778076_APPLY_N_COMMA_PARAMS(n, param) \
80 BOOST_PP_COMMA_IF(n) \
81 BOOST_MPL_PP_PARAMS(n, param) \
84 # define AUX778076_APPLY_N_PARTIAL_SPEC_PARAMS(n, param, def) \
85 BOOST_PP_COMMA_IF(n) \
86 BOOST_MPL_PP_PARTIAL_SPEC_PARAMS(n, param, def) \
89 # define AUX778076_APPLY_N_SPEC_PARAMS(n, param) \
90 BOOST_MPL_PP_ENUM(BOOST_PP_INC(n), param) \
94 #define BOOST_PP_ITERATION_PARAMS_1 \
95 (3,(0, BOOST_MPL_LIMIT_METAFUNCTION_ARITY, <boost/mpl/apply.hpp>))
96 #include BOOST_PP_ITERATE()
98 # if !defined(BOOST_MPL_CFG_NO_APPLY_TEMPLATE)
99 // real C++ version is already taken care of
100 # if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
104 #define AUX778076_COUNT_ARGS_PREFIX apply
105 #define AUX778076_COUNT_ARGS_DEFAULT na
106 #define AUX778076_COUNT_ARGS_ARITY BOOST_MPL_LIMIT_METAFUNCTION_ARITY
107 #include <boost/mpl/aux_/count_args.hpp>
112 typename F, AUX778076_APPLY_DEF_PARAMS(typename T, na)
115 : aux::apply_chooser<
116 aux::apply_count_args< AUX778076_APPLY_PARAMS(T) >::value
117 >::template result_< F, AUX778076_APPLY_PARAMS(T) >::type
121 # endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
122 # endif // BOOST_MPL_CFG_NO_APPLY_TEMPLATE
124 # undef AUX778076_APPLY_N_SPEC_PARAMS
125 # undef AUX778076_APPLY_N_PARTIAL_SPEC_PARAMS
126 # undef AUX778076_APPLY_N_COMMA_PARAMS
127 # undef AUX778076_APPLY_N_PARAMS
128 # undef AUX778076_APPLY_DEF_PARAMS
129 # undef AUX778076_APPLY_PARAMS
133 #endif // BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
134 #endif // BOOST_MPL_APPLY_HPP_INCLUDED
136 ///// iteration, depth == 1
138 // For gcc 4.4 compatability, we must include the
139 // BOOST_PP_ITERATION_DEPTH test inside an #else clause.
140 #else // BOOST_PP_IS_ITERATING
141 #if BOOST_PP_ITERATION_DEPTH() == 1
143 # define i_ BOOST_PP_FRAME_ITERATION(1)
146 typename F AUX778076_APPLY_N_COMMA_PARAMS(i_, typename T)
148 struct BOOST_PP_CAT(apply,i_)
149 #if !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
150 : BOOST_PP_CAT(apply_wrap,i_)<
151 typename lambda<F>::type
152 AUX778076_APPLY_N_COMMA_PARAMS(i_, T)
157 typedef typename BOOST_PP_CAT(apply_wrap,i_)<
158 typename lambda<F>::type
159 AUX778076_APPLY_N_COMMA_PARAMS(i_, T)
162 BOOST_MPL_AUX_LAMBDA_SUPPORT(
164 , BOOST_PP_CAT(apply,i_)
165 , (F AUX778076_APPLY_N_COMMA_PARAMS(i_,T))
170 #if defined(BOOST_MPL_CFG_MSVC_ETI_BUG)
171 /// workaround for ETI bug
173 struct BOOST_PP_CAT(apply,i_)<AUX778076_APPLY_N_SPEC_PARAMS(i_, int)>
179 # if !defined(BOOST_MPL_CFG_NO_APPLY_TEMPLATE)
180 # if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
182 #if i_ == BOOST_MPL_LIMIT_METAFUNCTION_ARITY
183 /// primary template (not a specialization!)
185 typename F AUX778076_APPLY_N_COMMA_PARAMS(i_, typename T)
188 : BOOST_PP_CAT(apply,i_)< F AUX778076_APPLY_N_COMMA_PARAMS(i_, T) >
193 typename F AUX778076_APPLY_N_COMMA_PARAMS(i_, typename T)
195 struct apply< F AUX778076_APPLY_N_PARTIAL_SPEC_PARAMS(i_, T, na) >
196 : BOOST_PP_CAT(apply,i_)< F AUX778076_APPLY_N_COMMA_PARAMS(i_, T) >
201 # else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
203 #if !defined(BOOST_MPL_CFG_NO_APPLY_TEMPLATE)
207 struct apply_chooser<i_>
210 typename F, AUX778076_APPLY_PARAMS(typename T)
214 typedef BOOST_PP_CAT(apply,i_)<
215 F AUX778076_APPLY_N_COMMA_PARAMS(i_, T)
223 # endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
224 # endif // BOOST_MPL_CFG_NO_APPLY_TEMPLATE
228 #endif // BOOST_PP_ITERATION_DEPTH()
229 #endif // BOOST_PP_IS_ITERATING