2 #if !defined(BOOST_PP_IS_ITERATING)
\r
6 #ifndef BOOST_MPL_APPLY_WRAP_HPP_INCLUDED
\r
7 #define BOOST_MPL_APPLY_WRAP_HPP_INCLUDED
\r
9 // Copyright Aleksey Gurtovoy 2000-2008
\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: apply_wrap.hpp 49272 2008-10-11 06:50:46Z agurtovoy $
\r
18 // $Date: 2008-10-11 02:50:46 -0400 (Sat, 11 Oct 2008) $
\r
19 // $Revision: 49272 $
\r
21 #if !defined(BOOST_MPL_PREPROCESSING_MODE)
\r
22 # include <boost/mpl/aux_/arity.hpp>
\r
23 # include <boost/mpl/aux_/has_apply.hpp>
\r
24 # include <boost/mpl/aux_/na.hpp>
\r
25 # include <boost/mpl/aux_/msvc_never_true.hpp>
\r
28 #include <boost/mpl/aux_/config/use_preprocessed.hpp>
\r
30 #if !defined(BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS) \
\r
31 && !defined(BOOST_MPL_PREPROCESSING_MODE)
\r
33 # define BOOST_MPL_PREPROCESSED_HEADER apply_wrap.hpp
\r
34 # include <boost/mpl/aux_/include_preprocessed.hpp>
\r
38 # include <boost/mpl/limits/arity.hpp>
\r
39 # include <boost/mpl/aux_/preprocessor/params.hpp>
\r
40 # include <boost/mpl/aux_/preprocessor/enum.hpp>
\r
41 # include <boost/mpl/aux_/preprocessor/add.hpp>
\r
42 # include <boost/mpl/aux_/config/bcc.hpp>
\r
43 # include <boost/mpl/aux_/config/ctps.hpp>
\r
44 # include <boost/mpl/aux_/config/dtp.hpp>
\r
45 # include <boost/mpl/aux_/config/eti.hpp>
\r
46 # include <boost/mpl/aux_/config/msvc.hpp>
\r
47 # include <boost/mpl/aux_/config/workaround.hpp>
\r
49 # include <boost/preprocessor/comma_if.hpp>
\r
50 # include <boost/preprocessor/logical/and.hpp>
\r
51 # include <boost/preprocessor/inc.hpp>
\r
52 # include <boost/preprocessor/iterate.hpp>
\r
55 namespace boost { namespace mpl {
\r
57 // local macros, #undef-ined at the end of the header
\r
58 # define AUX778076_APPLY_WRAP_PARAMS(n, param) \
\r
59 BOOST_MPL_PP_PARAMS(n, param) \
\r
62 # define AUX778076_APPLY_WRAP_SPEC_PARAMS(n, param) \
\r
63 BOOST_MPL_PP_ENUM(BOOST_PP_INC(n), param) \
\r
67 #define BOOST_PP_ITERATION_PARAMS_1 \
\r
68 (3,(0, BOOST_MPL_LIMIT_METAFUNCTION_ARITY, <boost/mpl/apply_wrap.hpp>))
\r
69 #include BOOST_PP_ITERATE()
\r
72 # undef AUX778076_APPLY_WRAP_SPEC_PARAMS
\r
73 # undef AUX778076_APPLY_WRAP_PARAMS
\r
77 #endif // BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
\r
78 #endif // BOOST_MPL_APPLY_WRAP_HPP_INCLUDED
\r
80 ///// iteration, depth == 1
\r
82 // For gcc 4.4 compatability, we must include the
\r
83 // BOOST_PP_ITERATION_DEPTH test inside an #else clause.
\r
84 #else // BOOST_PP_IS_ITERATING
\r
85 #if BOOST_PP_ITERATION_DEPTH() == 1
\r
87 # define i_ BOOST_PP_FRAME_ITERATION(1)
\r
89 # if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
\r
92 #define AUX778076_MSVC_DTW_NAME BOOST_PP_CAT(msvc_apply,i_)
\r
93 #define AUX778076_MSVC_DTW_ORIGINAL_NAME apply
\r
94 #define AUX778076_MSVC_DTW_ARITY i_
\r
95 #include <boost/mpl/aux_/msvc_dtw.hpp>
\r
98 typename F BOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, typename T)
\r
100 struct BOOST_PP_CAT(apply_wrap,i_)
\r
102 // Metafunction forwarding confuses vc6
\r
103 typedef typename BOOST_PP_CAT(msvc_apply,i_)<F>::template result_<
\r
104 AUX778076_APPLY_WRAP_PARAMS(i_, T)
\r
108 # elif defined(BOOST_MPL_CFG_BROKEN_DEFAULT_PARAMETERS_IN_NESTED_TEMPLATES)
\r
109 // MWCW/Borland version
\r
112 int N, typename F BOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, typename T)
\r
114 struct BOOST_PP_CAT(apply_wrap_impl,i_);
\r
116 #define BOOST_PP_ITERATION_PARAMS_2 \
\r
117 (3,(0, BOOST_MPL_LIMIT_METAFUNCTION_ARITY - i_, <boost/mpl/apply_wrap.hpp>))
\r
118 #include BOOST_PP_ITERATE()
\r
121 typename F BOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, typename T)
\r
123 struct BOOST_PP_CAT(apply_wrap,i_)
\r
124 : BOOST_PP_CAT(apply_wrap_impl,i_)<
\r
125 ::boost::mpl::aux::arity<F,i_>::value
\r
127 BOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, T)
\r
133 // ISO98 C++, with minor concession to vc7
\r
136 typename F BOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, typename T)
\r
138 , typename has_apply_ = typename aux::has_apply<F>::type
\r
141 struct BOOST_PP_CAT(apply_wrap,i_)
\r
142 // metafunction forwarding confuses MSVC 7.0
\r
143 #if !BOOST_WORKAROUND(BOOST_MSVC, == 1300)
\r
144 : F::template apply< AUX778076_APPLY_WRAP_PARAMS(i_, T) >
\r
148 typedef typename F::template apply<
\r
149 AUX778076_APPLY_WRAP_PARAMS(i_, T)
\r
154 #if i_ == 0 && !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
\r
155 template< typename F >
\r
156 struct BOOST_PP_CAT(apply_wrap,i_)<F,true_>
\r
162 # endif // workarounds
\r
164 #if defined(BOOST_MPL_CFG_MSVC_ETI_BUG)
\r
165 /// workaround for ETI bug
\r
167 struct BOOST_PP_CAT(apply_wrap,i_)<AUX778076_APPLY_WRAP_SPEC_PARAMS(i_, int)>
\r
175 ///// iteration, depth == 2
\r
177 #elif BOOST_PP_ITERATION_DEPTH() == 2
\r
179 # define j_ BOOST_PP_FRAME_ITERATION(2)
\r
181 #if i_ == 0 && j_ == 0 \
\r
182 && defined(BOOST_MPL_CFG_BCC590_WORKAROUNDS) \
\r
183 && !defined(BOOST_MPL_CFG_NO_HAS_APPLY)
\r
185 template< typename F, bool F_has_apply >
\r
186 struct apply_wrap_impl0_bcb {
\r
187 typedef typename F::template apply< na > type;
\r
190 template< typename F >
\r
191 struct apply_wrap_impl0_bcb< F, true > {
\r
192 typedef typename F::apply type;
\r
196 typename F BOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, typename T)
\r
198 struct BOOST_PP_CAT(apply_wrap_impl,i_)<
\r
199 BOOST_MPL_PP_ADD(i_, j_)
\r
201 BOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, T)
\r
204 typedef apply_wrap_impl0_bcb< F, aux::has_apply< F >::value >::type type;
\r
209 typename F BOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, typename T)
\r
211 struct BOOST_PP_CAT(apply_wrap_impl,i_)<
\r
212 BOOST_MPL_PP_ADD(i_, j_)
\r
214 BOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, T)
\r
217 typedef typename F::template apply<
\r
218 AUX778076_APPLY_WRAP_PARAMS(i_, T)
\r
219 #if i_ == 0 && j_ == 0
\r
220 /// since the defaults are "lost", we have to pass *something* even for nullary
\r
221 /// metafunction classes
\r
224 BOOST_PP_COMMA_IF(BOOST_PP_AND(i_, j_)) BOOST_MPL_PP_ENUM(j_, na)
\r
233 #endif // BOOST_PP_ITERATION_DEPTH()
\r
234 #endif // BOOST_PP_IS_ITERATING
\r