Chris@16
|
1
|
Chris@16
|
2 #if !defined(BOOST_PP_IS_ITERATING)
|
Chris@16
|
3
|
Chris@16
|
4 ///// header body
|
Chris@16
|
5
|
Chris@16
|
6 #ifndef BOOST_MPL_APPLY_HPP_INCLUDED
|
Chris@16
|
7 #define BOOST_MPL_APPLY_HPP_INCLUDED
|
Chris@16
|
8
|
Chris@16
|
9 // Copyright Aleksey Gurtovoy 2000-2004
|
Chris@16
|
10 //
|
Chris@16
|
11 // Distributed under the Boost Software License, Version 1.0.
|
Chris@16
|
12 // (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
13 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
14 //
|
Chris@16
|
15 // See http://www.boost.org/libs/mpl for documentation.
|
Chris@16
|
16
|
Chris@101
|
17 // $Id$
|
Chris@101
|
18 // $Date$
|
Chris@101
|
19 // $Revision$
|
Chris@16
|
20
|
Chris@16
|
21 #if !defined(BOOST_MPL_PREPROCESSING_MODE)
|
Chris@16
|
22 # include <boost/mpl/apply_fwd.hpp>
|
Chris@16
|
23 # include <boost/mpl/apply_wrap.hpp>
|
Chris@16
|
24 # include <boost/mpl/placeholders.hpp>
|
Chris@16
|
25 # include <boost/mpl/lambda.hpp>
|
Chris@16
|
26 # include <boost/mpl/aux_/na.hpp>
|
Chris@16
|
27 # include <boost/mpl/aux_/lambda_support.hpp>
|
Chris@16
|
28 #endif
|
Chris@16
|
29
|
Chris@16
|
30 #include <boost/mpl/aux_/config/use_preprocessed.hpp>
|
Chris@16
|
31
|
Chris@16
|
32 #if !defined(BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS) \
|
Chris@16
|
33 && !defined(BOOST_MPL_PREPROCESSING_MODE)
|
Chris@16
|
34
|
Chris@16
|
35 # define BOOST_MPL_PREPROCESSED_HEADER apply.hpp
|
Chris@16
|
36 # include <boost/mpl/aux_/include_preprocessed.hpp>
|
Chris@16
|
37
|
Chris@16
|
38 #else
|
Chris@16
|
39
|
Chris@16
|
40 # include <boost/mpl/limits/arity.hpp>
|
Chris@16
|
41 # include <boost/mpl/aux_/preprocessor/params.hpp>
|
Chris@16
|
42 # include <boost/mpl/aux_/preprocessor/default_params.hpp>
|
Chris@16
|
43 # include <boost/mpl/aux_/preprocessor/partial_spec_params.hpp>
|
Chris@16
|
44 # include <boost/mpl/aux_/preprocessor/enum.hpp>
|
Chris@16
|
45 # include <boost/mpl/aux_/config/lambda.hpp>
|
Chris@16
|
46 # include <boost/mpl/aux_/config/dtp.hpp>
|
Chris@16
|
47 # include <boost/mpl/aux_/nttp_decl.hpp>
|
Chris@16
|
48 # include <boost/mpl/aux_/config/eti.hpp>
|
Chris@16
|
49 # include <boost/mpl/aux_/config/msvc.hpp>
|
Chris@16
|
50 # include <boost/mpl/aux_/config/workaround.hpp>
|
Chris@16
|
51
|
Chris@16
|
52 # include <boost/preprocessor/comma_if.hpp>
|
Chris@16
|
53 # include <boost/preprocessor/inc.hpp>
|
Chris@16
|
54 # include <boost/preprocessor/iterate.hpp>
|
Chris@16
|
55 # include <boost/preprocessor/cat.hpp>
|
Chris@16
|
56
|
Chris@16
|
57 namespace boost { namespace mpl {
|
Chris@16
|
58
|
Chris@16
|
59 // local macros, #undef-ined at the end of the header
|
Chris@16
|
60 # define AUX778076_APPLY_PARAMS(param) \
|
Chris@16
|
61 BOOST_MPL_PP_PARAMS( \
|
Chris@16
|
62 BOOST_MPL_LIMIT_METAFUNCTION_ARITY \
|
Chris@16
|
63 , param \
|
Chris@16
|
64 ) \
|
Chris@16
|
65 /**/
|
Chris@16
|
66
|
Chris@16
|
67 # define AUX778076_APPLY_DEF_PARAMS(param, value) \
|
Chris@16
|
68 BOOST_MPL_PP_DEFAULT_PARAMS( \
|
Chris@16
|
69 BOOST_MPL_LIMIT_METAFUNCTION_ARITY \
|
Chris@16
|
70 , param \
|
Chris@16
|
71 , value \
|
Chris@16
|
72 ) \
|
Chris@16
|
73 /**/
|
Chris@16
|
74
|
Chris@16
|
75 # define AUX778076_APPLY_N_PARAMS(n, param) \
|
Chris@16
|
76 BOOST_MPL_PP_PARAMS(n, param) \
|
Chris@16
|
77 /**/
|
Chris@16
|
78
|
Chris@16
|
79 # define AUX778076_APPLY_N_COMMA_PARAMS(n, param) \
|
Chris@16
|
80 BOOST_PP_COMMA_IF(n) \
|
Chris@16
|
81 BOOST_MPL_PP_PARAMS(n, param) \
|
Chris@16
|
82 /**/
|
Chris@16
|
83
|
Chris@16
|
84 # define AUX778076_APPLY_N_PARTIAL_SPEC_PARAMS(n, param, def) \
|
Chris@16
|
85 BOOST_PP_COMMA_IF(n) \
|
Chris@16
|
86 BOOST_MPL_PP_PARTIAL_SPEC_PARAMS(n, param, def) \
|
Chris@16
|
87 /**/
|
Chris@16
|
88
|
Chris@16
|
89 # define AUX778076_APPLY_N_SPEC_PARAMS(n, param) \
|
Chris@16
|
90 BOOST_MPL_PP_ENUM(BOOST_PP_INC(n), param) \
|
Chris@16
|
91 /**/
|
Chris@16
|
92
|
Chris@16
|
93
|
Chris@16
|
94 #define BOOST_PP_ITERATION_PARAMS_1 \
|
Chris@16
|
95 (3,(0, BOOST_MPL_LIMIT_METAFUNCTION_ARITY, <boost/mpl/apply.hpp>))
|
Chris@16
|
96 #include BOOST_PP_ITERATE()
|
Chris@16
|
97
|
Chris@16
|
98 # if !defined(BOOST_MPL_CFG_NO_APPLY_TEMPLATE)
|
Chris@16
|
99 // real C++ version is already taken care of
|
Chris@16
|
100 # if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
Chris@16
|
101
|
Chris@16
|
102 namespace aux {
|
Chris@16
|
103 // apply_count_args
|
Chris@16
|
104 #define AUX778076_COUNT_ARGS_PREFIX apply
|
Chris@16
|
105 #define AUX778076_COUNT_ARGS_DEFAULT na
|
Chris@16
|
106 #define AUX778076_COUNT_ARGS_ARITY BOOST_MPL_LIMIT_METAFUNCTION_ARITY
|
Chris@16
|
107 #include <boost/mpl/aux_/count_args.hpp>
|
Chris@16
|
108 }
|
Chris@16
|
109
|
Chris@16
|
110
|
Chris@16
|
111 template<
|
Chris@16
|
112 typename F, AUX778076_APPLY_DEF_PARAMS(typename T, na)
|
Chris@16
|
113 >
|
Chris@16
|
114 struct apply
|
Chris@16
|
115 : aux::apply_chooser<
|
Chris@16
|
116 aux::apply_count_args< AUX778076_APPLY_PARAMS(T) >::value
|
Chris@16
|
117 >::template result_< F, AUX778076_APPLY_PARAMS(T) >::type
|
Chris@16
|
118 {
|
Chris@16
|
119 };
|
Chris@16
|
120
|
Chris@16
|
121 # endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
Chris@16
|
122 # endif // BOOST_MPL_CFG_NO_APPLY_TEMPLATE
|
Chris@16
|
123
|
Chris@16
|
124 # undef AUX778076_APPLY_N_SPEC_PARAMS
|
Chris@16
|
125 # undef AUX778076_APPLY_N_PARTIAL_SPEC_PARAMS
|
Chris@16
|
126 # undef AUX778076_APPLY_N_COMMA_PARAMS
|
Chris@16
|
127 # undef AUX778076_APPLY_N_PARAMS
|
Chris@16
|
128 # undef AUX778076_APPLY_DEF_PARAMS
|
Chris@16
|
129 # undef AUX778076_APPLY_PARAMS
|
Chris@16
|
130
|
Chris@16
|
131 }}
|
Chris@16
|
132
|
Chris@16
|
133 #endif // BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
|
Chris@16
|
134 #endif // BOOST_MPL_APPLY_HPP_INCLUDED
|
Chris@16
|
135
|
Chris@16
|
136 ///// iteration, depth == 1
|
Chris@16
|
137
|
Chris@16
|
138 // For gcc 4.4 compatability, we must include the
|
Chris@16
|
139 // BOOST_PP_ITERATION_DEPTH test inside an #else clause.
|
Chris@16
|
140 #else // BOOST_PP_IS_ITERATING
|
Chris@16
|
141 #if BOOST_PP_ITERATION_DEPTH() == 1
|
Chris@16
|
142
|
Chris@16
|
143 # define i_ BOOST_PP_FRAME_ITERATION(1)
|
Chris@16
|
144
|
Chris@16
|
145 template<
|
Chris@16
|
146 typename F AUX778076_APPLY_N_COMMA_PARAMS(i_, typename T)
|
Chris@16
|
147 >
|
Chris@16
|
148 struct BOOST_PP_CAT(apply,i_)
|
Chris@16
|
149 #if !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
Chris@16
|
150 : BOOST_PP_CAT(apply_wrap,i_)<
|
Chris@16
|
151 typename lambda<F>::type
|
Chris@16
|
152 AUX778076_APPLY_N_COMMA_PARAMS(i_, T)
|
Chris@16
|
153 >
|
Chris@16
|
154 {
|
Chris@16
|
155 #else
|
Chris@16
|
156 {
|
Chris@16
|
157 typedef typename BOOST_PP_CAT(apply_wrap,i_)<
|
Chris@16
|
158 typename lambda<F>::type
|
Chris@16
|
159 AUX778076_APPLY_N_COMMA_PARAMS(i_, T)
|
Chris@16
|
160 >::type type;
|
Chris@16
|
161 #endif
|
Chris@16
|
162 BOOST_MPL_AUX_LAMBDA_SUPPORT(
|
Chris@16
|
163 BOOST_PP_INC(i_)
|
Chris@16
|
164 , BOOST_PP_CAT(apply,i_)
|
Chris@16
|
165 , (F AUX778076_APPLY_N_COMMA_PARAMS(i_,T))
|
Chris@16
|
166 )
|
Chris@16
|
167 };
|
Chris@16
|
168
|
Chris@16
|
169
|
Chris@16
|
170 #if defined(BOOST_MPL_CFG_MSVC_ETI_BUG)
|
Chris@16
|
171 /// workaround for ETI bug
|
Chris@16
|
172 template<>
|
Chris@16
|
173 struct BOOST_PP_CAT(apply,i_)<AUX778076_APPLY_N_SPEC_PARAMS(i_, int)>
|
Chris@16
|
174 {
|
Chris@16
|
175 typedef int type;
|
Chris@16
|
176 };
|
Chris@16
|
177 #endif
|
Chris@16
|
178
|
Chris@16
|
179 # if !defined(BOOST_MPL_CFG_NO_APPLY_TEMPLATE)
|
Chris@16
|
180 # if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
Chris@16
|
181
|
Chris@16
|
182 #if i_ == BOOST_MPL_LIMIT_METAFUNCTION_ARITY
|
Chris@16
|
183 /// primary template (not a specialization!)
|
Chris@16
|
184 template<
|
Chris@16
|
185 typename F AUX778076_APPLY_N_COMMA_PARAMS(i_, typename T)
|
Chris@16
|
186 >
|
Chris@16
|
187 struct apply
|
Chris@16
|
188 : BOOST_PP_CAT(apply,i_)< F AUX778076_APPLY_N_COMMA_PARAMS(i_, T) >
|
Chris@16
|
189 {
|
Chris@16
|
190 };
|
Chris@16
|
191 #else
|
Chris@16
|
192 template<
|
Chris@16
|
193 typename F AUX778076_APPLY_N_COMMA_PARAMS(i_, typename T)
|
Chris@16
|
194 >
|
Chris@16
|
195 struct apply< F AUX778076_APPLY_N_PARTIAL_SPEC_PARAMS(i_, T, na) >
|
Chris@16
|
196 : BOOST_PP_CAT(apply,i_)< F AUX778076_APPLY_N_COMMA_PARAMS(i_, T) >
|
Chris@16
|
197 {
|
Chris@16
|
198 };
|
Chris@16
|
199 #endif
|
Chris@16
|
200
|
Chris@16
|
201 # else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
Chris@16
|
202
|
Chris@16
|
203 #if !defined(BOOST_MPL_CFG_NO_APPLY_TEMPLATE)
|
Chris@16
|
204 namespace aux {
|
Chris@16
|
205
|
Chris@16
|
206 template<>
|
Chris@16
|
207 struct apply_chooser<i_>
|
Chris@16
|
208 {
|
Chris@16
|
209 template<
|
Chris@16
|
210 typename F, AUX778076_APPLY_PARAMS(typename T)
|
Chris@16
|
211 >
|
Chris@16
|
212 struct result_
|
Chris@16
|
213 {
|
Chris@16
|
214 typedef BOOST_PP_CAT(apply,i_)<
|
Chris@16
|
215 F AUX778076_APPLY_N_COMMA_PARAMS(i_, T)
|
Chris@16
|
216 > type;
|
Chris@16
|
217 };
|
Chris@16
|
218 };
|
Chris@16
|
219
|
Chris@16
|
220 } // namespace aux
|
Chris@16
|
221 #endif
|
Chris@16
|
222
|
Chris@16
|
223 # endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
Chris@16
|
224 # endif // BOOST_MPL_CFG_NO_APPLY_TEMPLATE
|
Chris@16
|
225
|
Chris@16
|
226 # undef i_
|
Chris@16
|
227
|
Chris@16
|
228 #endif // BOOST_PP_ITERATION_DEPTH()
|
Chris@16
|
229 #endif // BOOST_PP_IS_ITERATING
|