1
2#if !defined(BOOST_PP_IS_ITERATING)
3
4///// header body
5
6#ifndef BOOST_MPL_APPLY_WRAP_HPP_INCLUDED
7#define BOOST_MPL_APPLY_WRAP_HPP_INCLUDED
8
9// Copyright Aleksey Gurtovoy 2000-2008
10//
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)
14//
15// See http://www.boost.org/libs/mpl for documentation.
16
17// $Id$
18// $Date$
19// $Revision$
20
21#if !defined(BOOST_MPL_PREPROCESSING_MODE)
22# include <boost/mpl/aux_/arity.hpp>
23# include <boost/mpl/aux_/has_apply.hpp>
24# include <boost/mpl/aux_/na.hpp>
25# include <boost/mpl/aux_/msvc_never_true.hpp>
26#endif
27
28#include <boost/mpl/aux_/config/use_preprocessed.hpp>
29
30#if !defined(BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS) \
31 && !defined(BOOST_MPL_PREPROCESSING_MODE)
32
33# define BOOST_MPL_PREPROCESSED_HEADER apply_wrap.hpp
34# include <boost/mpl/aux_/include_preprocessed.hpp>
35
36#else
37
38# include <boost/mpl/limits/arity.hpp>
39# include <boost/mpl/aux_/preprocessor/params.hpp>
40# include <boost/mpl/aux_/preprocessor/enum.hpp>
41# include <boost/mpl/aux_/preprocessor/add.hpp>
42# include <boost/mpl/aux_/config/bcc.hpp>
43# include <boost/mpl/aux_/config/ctps.hpp>
44# include <boost/mpl/aux_/config/dtp.hpp>
45# include <boost/mpl/aux_/config/eti.hpp>
46# include <boost/mpl/aux_/config/msvc.hpp>
47# include <boost/mpl/aux_/config/workaround.hpp>
48
49# include <boost/preprocessor/comma_if.hpp>
50# include <boost/preprocessor/logical/and.hpp>
51# include <boost/preprocessor/inc.hpp>
52# include <boost/preprocessor/iterate.hpp>
53
54
55namespace boost { namespace mpl {
56
57// local macros, #undef-ined at the end of the header
58# define AUX778076_APPLY_WRAP_PARAMS(n, param) \
59 BOOST_MPL_PP_PARAMS(n, param) \
60 /**/
61
62# define AUX778076_APPLY_WRAP_SPEC_PARAMS(n, param) \
63 BOOST_MPL_PP_ENUM(BOOST_PP_INC(n), param) \
64 /**/
65
66
67#define BOOST_PP_ITERATION_PARAMS_1 \
68 (3,(0, BOOST_MPL_LIMIT_METAFUNCTION_ARITY, <boost/mpl/apply_wrap.hpp>))
69#include BOOST_PP_ITERATE()
70
71
72# undef AUX778076_APPLY_WRAP_SPEC_PARAMS
73# undef AUX778076_APPLY_WRAP_PARAMS
74
75}}
76
77#endif // BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
78#endif // BOOST_MPL_APPLY_WRAP_HPP_INCLUDED
79
80///// iteration, depth == 1
81
82// For gcc 4.4 compatability, we must include the
83// BOOST_PP_ITERATION_DEPTH test inside an #else clause.
84#else // BOOST_PP_IS_ITERATING
85#if BOOST_PP_ITERATION_DEPTH() == 1
86
87# define i_ BOOST_PP_FRAME_ITERATION(1)
88
89# if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
90// MSVC version
91
92#define AUX778076_MSVC_DTW_NAME BOOST_PP_CAT(msvc_apply,i_)
93#define AUX778076_MSVC_DTW_ORIGINAL_NAME apply
94#define AUX778076_MSVC_DTW_ARITY i_
95#include <boost/mpl/aux_/msvc_dtw.hpp>
96
97template<
98 typename F BOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, typename T)
99 >
100struct BOOST_PP_CAT(apply_wrap,i_)
101{
102 // Metafunction forwarding confuses vc6
103 typedef typename BOOST_PP_CAT(msvc_apply,i_)<F>::template result_<
104 AUX778076_APPLY_WRAP_PARAMS(i_, T)
105 >::type type;
106};
107
108# elif defined(BOOST_MPL_CFG_BROKEN_DEFAULT_PARAMETERS_IN_NESTED_TEMPLATES)
109// MWCW/Borland version
110
111template<
112 int N, typename F BOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, typename T)
113 >
114struct BOOST_PP_CAT(apply_wrap_impl,i_);
115
116#define BOOST_PP_ITERATION_PARAMS_2 \
117 (3,(0, BOOST_MPL_LIMIT_METAFUNCTION_ARITY - i_, <boost/mpl/apply_wrap.hpp>))
118#include BOOST_PP_ITERATE()
119
120template<
121 typename F BOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, typename T)
122 >
123struct BOOST_PP_CAT(apply_wrap,i_)
124 : BOOST_PP_CAT(apply_wrap_impl,i_)<
125 ::boost::mpl::aux::arity<F,i_>::value
126 , F
127 BOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, T)
128 >::type
129{
130};
131
132# else
133// ISO98 C++, with minor concession to vc7
134
135template<
136 typename F BOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, typename T)
137#if i_ == 0
138 , typename has_apply_ = typename aux::has_apply<F>::type
139#endif
140 >
141struct BOOST_PP_CAT(apply_wrap,i_)
142// metafunction forwarding confuses MSVC 7.0
143#if !BOOST_WORKAROUND(BOOST_MSVC, == 1300)
144 : F::template apply< AUX778076_APPLY_WRAP_PARAMS(i_, T) >
145{
146#else
147{
148 typedef typename F::template apply<
149 AUX778076_APPLY_WRAP_PARAMS(i_, T)
150 >::type type;
151#endif
152};
153
154#if i_ == 0 && !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
155template< typename F >
156struct BOOST_PP_CAT(apply_wrap,i_)<F,true_>
157 : F::apply
158{
159};
160#endif
161
162# endif // workarounds
163
164#if defined(BOOST_MPL_CFG_MSVC_ETI_BUG)
165/// workaround for ETI bug
166template<>
167struct BOOST_PP_CAT(apply_wrap,i_)<AUX778076_APPLY_WRAP_SPEC_PARAMS(i_, int)>
168{
169 typedef int type;
170};
171#endif
172
173# undef i_
174
175///// iteration, depth == 2
176
177#elif BOOST_PP_ITERATION_DEPTH() == 2
178
179# define j_ BOOST_PP_FRAME_ITERATION(2)
180
181#if i_ == 0 && j_ == 0 \
182 && defined(BOOST_MPL_CFG_BCC590_WORKAROUNDS) \
183 && !defined(BOOST_MPL_CFG_NO_HAS_APPLY)
184
185template< typename F, bool F_has_apply >
186struct apply_wrap_impl0_bcb {
187 typedef typename F::template apply< na > type;
188};
189
190template< typename F >
191struct apply_wrap_impl0_bcb< F, true > {
192 typedef typename F::apply type;
193};
194
195template<
196 typename F BOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, typename T)
197 >
198struct BOOST_PP_CAT(apply_wrap_impl,i_)<
199 BOOST_MPL_PP_ADD(i_, j_)
200 , F
201 BOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, T)
202 >
203{
204 typedef apply_wrap_impl0_bcb< F, aux::has_apply< F >::value >::type type;
205};
206#else
207
208template<
209 typename F BOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, typename T)
210 >
211struct BOOST_PP_CAT(apply_wrap_impl,i_)<
212 BOOST_MPL_PP_ADD(i_, j_)
213 , F
214 BOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, T)
215 >
216{
217 typedef typename F::template apply<
218 AUX778076_APPLY_WRAP_PARAMS(i_, T)
219#if i_ == 0 && j_ == 0
220/// since the defaults are "lost", we have to pass *something* even for nullary
221/// metafunction classes
222 na
223#else
224 BOOST_PP_COMMA_IF(BOOST_PP_AND(i_, j_)) BOOST_MPL_PP_ENUM(j_, na)
225#endif
226 > type;
227};
228
229#endif
230
231# undef j_
232
233#endif // BOOST_PP_ITERATION_DEPTH()
234#endif // BOOST_PP_IS_ITERATING
235

source code of boost/boost/mpl/apply_wrap.hpp