Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/parameter/preprocessor.hpp @ 16:2665513ce2d3
Add boost headers
author | Chris Cannam |
---|---|
date | Tue, 05 Aug 2014 11:11:38 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
15:663ca0da4350 | 16:2665513ce2d3 |
---|---|
1 // Copyright Daniel Wallin 2006. Use, modification and distribution is | |
2 // subject to the Boost Software License, Version 1.0. (See accompanying | |
3 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |
4 | |
5 #ifndef BOOST_PARAMETER_PREPROCESSOR_060206_HPP | |
6 # define BOOST_PARAMETER_PREPROCESSOR_060206_HPP | |
7 | |
8 # include <boost/parameter/parameters.hpp> | |
9 # include <boost/parameter/binding.hpp> | |
10 # include <boost/parameter/match.hpp> | |
11 | |
12 # include <boost/parameter/aux_/parenthesized_type.hpp> | |
13 # include <boost/parameter/aux_/cast.hpp> | |
14 # include <boost/parameter/aux_/preprocessor/flatten.hpp> | |
15 | |
16 # include <boost/preprocessor/repetition/repeat_from_to.hpp> | |
17 # include <boost/preprocessor/comparison/equal.hpp> | |
18 # include <boost/preprocessor/control/if.hpp> | |
19 # include <boost/preprocessor/control/iif.hpp> | |
20 # include <boost/preprocessor/control/expr_if.hpp> | |
21 # include <boost/preprocessor/repetition/enum_params.hpp> | |
22 # include <boost/preprocessor/repetition/enum_binary_params.hpp> | |
23 # include <boost/preprocessor/repetition/enum_trailing.hpp> | |
24 # include <boost/preprocessor/seq/first_n.hpp> | |
25 # include <boost/preprocessor/seq/for_each_product.hpp> | |
26 # include <boost/preprocessor/seq/for_each_i.hpp> | |
27 # include <boost/preprocessor/tuple/elem.hpp> | |
28 # include <boost/preprocessor/tuple/eat.hpp> | |
29 # include <boost/preprocessor/seq/fold_left.hpp> | |
30 # include <boost/preprocessor/seq/push_back.hpp> | |
31 # include <boost/preprocessor/seq/size.hpp> | |
32 # include <boost/preprocessor/seq/enum.hpp> | |
33 # include <boost/preprocessor/seq/push_back.hpp> | |
34 | |
35 # include <boost/preprocessor/detail/is_nullary.hpp> | |
36 | |
37 # include <boost/mpl/always.hpp> | |
38 # include <boost/mpl/apply_wrap.hpp> | |
39 | |
40 # if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) | |
41 # include <boost/type.hpp> | |
42 # endif | |
43 | |
44 namespace boost { namespace parameter { namespace aux { | |
45 | |
46 # if ! defined(BOOST_NO_SFINAE) && ! BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x592)) | |
47 | |
48 // Given Match, which is "void x" where x is an argument matching | |
49 // criterion, extract a corresponding MPL predicate. | |
50 template <class Match> | |
51 struct unwrap_predicate; | |
52 | |
53 // Match anything | |
54 template <> | |
55 struct unwrap_predicate<void*> | |
56 { | |
57 typedef mpl::always<mpl::true_> type; | |
58 }; | |
59 | |
60 #if BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x580)) | |
61 | |
62 typedef void* voidstar; | |
63 | |
64 // A matching predicate is explicitly specified | |
65 template <class Predicate> | |
66 struct unwrap_predicate<voidstar (Predicate)> | |
67 { | |
68 typedef Predicate type; | |
69 }; | |
70 | |
71 #else | |
72 | |
73 // A matching predicate is explicitly specified | |
74 template <class Predicate> | |
75 struct unwrap_predicate<void *(Predicate)> | |
76 { | |
77 typedef Predicate type; | |
78 }; | |
79 | |
80 #endif | |
81 | |
82 | |
83 // A type to which the argument is supposed to be convertible is | |
84 // specified | |
85 template <class Target> | |
86 struct unwrap_predicate<void (Target)> | |
87 { | |
88 typedef is_convertible<mpl::_, Target> type; | |
89 }; | |
90 | |
91 // Recast the ParameterSpec's nested match metafunction as a free metafunction | |
92 template < | |
93 class Parameters | |
94 , BOOST_PP_ENUM_BINARY_PARAMS( | |
95 BOOST_PARAMETER_MAX_ARITY, class A, = boost::parameter::void_ BOOST_PP_INTERCEPT | |
96 ) | |
97 > | |
98 struct match | |
99 : Parameters::template match< | |
100 BOOST_PP_ENUM_PARAMS(BOOST_PARAMETER_MAX_ARITY, A) | |
101 > | |
102 {}; | |
103 # endif | |
104 | |
105 # if BOOST_WORKAROUND(BOOST_MSVC, == 1300) | |
106 | |
107 // Function template argument deduction does many of the same things | |
108 // as type matching during partial specialization, so we call a | |
109 // function template to "store" T into the type memory addressed by | |
110 // void(*)(T). | |
111 template <class T> | |
112 msvc_store_type<T,void*(*)(void**(T))> | |
113 msvc_store_predicate_type(void*(*)(void**(T))); | |
114 | |
115 template <class T> | |
116 msvc_store_type<boost::is_convertible<mpl::_,T>,void*(*)(void*(T))> | |
117 msvc_store_predicate_type(void*(*)(void*(T))); | |
118 | |
119 template <class FunctionType> | |
120 struct unwrap_predicate | |
121 { | |
122 static FunctionType f; | |
123 | |
124 // We don't want the function to be evaluated, just instantiated, | |
125 // so protect it inside of sizeof. | |
126 enum { dummy = sizeof(msvc_store_predicate_type(f)) }; | |
127 | |
128 // Now pull the type out of the instantiated base class | |
129 typedef typename msvc_type_memory<FunctionType>::storage::type type; | |
130 }; | |
131 | |
132 template <> | |
133 struct unwrap_predicate<void*(*)(void**)> | |
134 { | |
135 typedef mpl::always<mpl::true_> type; | |
136 }; | |
137 | |
138 # endif | |
139 | |
140 # undef false_ | |
141 | |
142 template < | |
143 class Parameters | |
144 , BOOST_PP_ENUM_BINARY_PARAMS( | |
145 BOOST_PARAMETER_MAX_ARITY, class A, = boost::parameter::void_ BOOST_PP_INTERCEPT | |
146 ) | |
147 > | |
148 struct argument_pack | |
149 { | |
150 typedef typename make_arg_list< | |
151 typename BOOST_PARAMETER_build_arg_list( | |
152 BOOST_PARAMETER_MAX_ARITY, make_items, typename Parameters::parameter_spec, A | |
153 )::type | |
154 , typename Parameters::deduced_list | |
155 , tag_keyword_arg | |
156 , mpl::false_ | |
157 >::type result; | |
158 typedef typename mpl::first<result>::type type; | |
159 }; | |
160 | |
161 # if 1 //BOOST_WORKAROUND(BOOST_MSVC, < 1300) | |
162 // Works around VC6 problem where it won't accept rvalues. | |
163 template <class T> | |
164 T& as_lvalue(T& value, long) | |
165 { | |
166 return value; | |
167 } | |
168 | |
169 template <class T> | |
170 T const& as_lvalue(T const& value, int) | |
171 { | |
172 return value; | |
173 } | |
174 # endif | |
175 | |
176 | |
177 # if BOOST_WORKAROUND(BOOST_MSVC, < 1300) \ | |
178 || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) | |
179 | |
180 template <class Predicate, class T, class Args> | |
181 struct apply_predicate | |
182 { | |
183 BOOST_MPL_ASSERT(( | |
184 mpl::and_<mpl::false_,T> | |
185 )); | |
186 | |
187 typedef typename mpl::if_< | |
188 typename mpl::apply2<Predicate,T,Args>::type | |
189 , char | |
190 , int | |
191 >::type type; | |
192 }; | |
193 | |
194 template <class P> | |
195 struct funptr_predicate | |
196 { | |
197 static P p; | |
198 | |
199 template <class T, class Args, class P0> | |
200 static typename apply_predicate<P0,T,Args>::type | |
201 check_predicate(type<T>, Args*, void**(*)(P0)); | |
202 | |
203 template <class T, class Args, class P0> | |
204 static typename mpl::if_< | |
205 is_convertible<T,P0> | |
206 , char | |
207 , int | |
208 >::type check_predicate(type<T>, Args*, void*(*)(P0)); | |
209 | |
210 template <class T, class Args> | |
211 struct apply | |
212 { | |
213 BOOST_STATIC_CONSTANT(bool, result = | |
214 sizeof(check_predicate(boost::type<T>(), (Args*)0, &p)) == 1 | |
215 ); | |
216 | |
217 typedef mpl::bool_<apply<T,Args>::result> type; | |
218 }; | |
219 }; | |
220 | |
221 template <> | |
222 struct funptr_predicate<void**> | |
223 : mpl::always<mpl::true_> | |
224 {}; | |
225 | |
226 # endif | |
227 | |
228 }}} // namespace boost::parameter::aux | |
229 | |
230 # if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) | |
231 // From Paul Mensonides | |
232 # define BOOST_PARAMETER_IS_NULLARY(x) \ | |
233 BOOST_PP_SPLIT(1, BOOST_PARAMETER_IS_NULLARY_C x BOOST_PP_COMMA() 0) \ | |
234 /**/ | |
235 # define BOOST_PARAMETER_IS_NULLARY_C() \ | |
236 ~, 1 BOOST_PP_RPAREN() \ | |
237 BOOST_PP_TUPLE_EAT(2) BOOST_PP_LPAREN() ~ \ | |
238 /**/ | |
239 # else | |
240 # define BOOST_PARAMETER_IS_NULLARY(x) BOOST_PP_IS_NULLARY(x) | |
241 # endif | |
242 | |
243 # define BOOST_PARAMETER_MEMBER_FUNCTION_CHECK_STATIC_static () | |
244 # define BOOST_PARAMETER_MEMBER_FUNCTION_IS_STATIC(name) \ | |
245 BOOST_PARAMETER_IS_NULLARY( \ | |
246 BOOST_PP_CAT(BOOST_PARAMETER_MEMBER_FUNCTION_CHECK_STATIC_,name) \ | |
247 ) | |
248 | |
249 # if !defined(BOOST_MSVC) | |
250 # define BOOST_PARAMETER_MEMBER_FUNCTION_STRIP_STATIC_static | |
251 # define BOOST_PARAMETER_MEMBER_FUNCTION_STRIP_STATIC(name) \ | |
252 BOOST_PP_CAT(BOOST_PARAMETER_MEMBER_FUNCTION_STRIP_STATIC_, name) | |
253 # else | |
254 // Workaround for MSVC preprocessor. | |
255 // | |
256 // When stripping static from "static f", msvc will produce | |
257 // " f". The leading whitespace doesn't go away when pasting | |
258 // the token with something else, so this thing is a hack to | |
259 // strip the whitespace. | |
260 # define BOOST_PARAMETER_MEMBER_FUNCTION_STRIP_STATIC_static ( | |
261 # define BOOST_PARAMETER_MEMBER_FUNCTION_STRIP_STATIC_AUX(name) \ | |
262 BOOST_PP_CAT(BOOST_PARAMETER_MEMBER_FUNCTION_STRIP_STATIC_, name)) | |
263 # define BOOST_PARAMETER_MEMBER_FUNCTION_STRIP_STATIC(name) \ | |
264 BOOST_PP_SEQ_HEAD( \ | |
265 BOOST_PARAMETER_MEMBER_FUNCTION_STRIP_STATIC_AUX(name) \ | |
266 ) | |
267 # endif | |
268 | |
269 # define BOOST_PARAMETER_MEMBER_FUNCTION_STATIC(name) \ | |
270 BOOST_PP_EXPR_IF( \ | |
271 BOOST_PARAMETER_MEMBER_FUNCTION_IS_STATIC(name) \ | |
272 , static \ | |
273 ) | |
274 | |
275 # define BOOST_PARAMETER_MEMBER_FUNCTION_NAME(name) \ | |
276 BOOST_PP_IF( \ | |
277 BOOST_PARAMETER_MEMBER_FUNCTION_IS_STATIC(name) \ | |
278 , BOOST_PARAMETER_MEMBER_FUNCTION_STRIP_STATIC \ | |
279 , name BOOST_PP_TUPLE_EAT(1) \ | |
280 )(name) | |
281 | |
282 // Calculates [begin, end) arity range. | |
283 | |
284 # define BOOST_PARAMETER_ARITY_RANGE_M_optional(state) state | |
285 # define BOOST_PARAMETER_ARITY_RANGE_M_deduced_optional(state) state | |
286 # define BOOST_PARAMETER_ARITY_RANGE_M_required(state) BOOST_PP_INC(state) | |
287 # define BOOST_PARAMETER_ARITY_RANGE_M_deduced_required(state) BOOST_PP_INC(state) | |
288 | |
289 # define BOOST_PARAMETER_ARITY_RANGE_M(s, state, x) \ | |
290 BOOST_PP_CAT( \ | |
291 BOOST_PARAMETER_ARITY_RANGE_M_ \ | |
292 , BOOST_PARAMETER_FN_ARG_QUALIFIER(x) \ | |
293 )(state) | |
294 /**/ | |
295 | |
296 # define BOOST_PARAMETER_ARITY_RANGE(args) \ | |
297 ( \ | |
298 BOOST_PP_SEQ_FOLD_LEFT(BOOST_PARAMETER_ARITY_RANGE_M, 0, args) \ | |
299 , BOOST_PP_INC(BOOST_PP_SEQ_SIZE(args)) \ | |
300 ) | |
301 /**/ | |
302 | |
303 // Accessor macros for the argument specs tuple. | |
304 # define BOOST_PARAMETER_FN_ARG_QUALIFIER(x) \ | |
305 BOOST_PP_TUPLE_ELEM(4,0,x) | |
306 /**/ | |
307 | |
308 # define BOOST_PARAMETER_FN_ARG_NAME(x) \ | |
309 BOOST_PP_TUPLE_ELEM(4,1,x) | |
310 /**/ | |
311 | |
312 # define BOOST_PARAMETER_FN_ARG_PRED(x) \ | |
313 BOOST_PP_TUPLE_ELEM(4,2,x) | |
314 /**/ | |
315 | |
316 # define BOOST_PARAMETER_FN_ARG_DEFAULT(x) \ | |
317 BOOST_PP_TUPLE_ELEM(4,3,x) | |
318 /**/ | |
319 | |
320 # define BOOST_PARAMETETER_FUNCTION_EAT_KEYWORD_QUALIFIER_out(x) | |
321 # define BOOST_PARAMETETER_FUNCTION_EAT_KEYWORD_QUALIFIER_in_out(x) | |
322 | |
323 // Returns 1 if x is either "out(k)" or "in_out(k)". | |
324 # define BOOST_PARAMETER_FUNCTION_IS_KEYWORD_QUALIFIER(x) \ | |
325 BOOST_PP_IS_EMPTY( \ | |
326 BOOST_PP_CAT(BOOST_PARAMETETER_FUNCTION_EAT_KEYWORD_QUALIFIER_, x) \ | |
327 ) \ | |
328 /**/ | |
329 | |
330 # define BOOST_PARAMETETER_FUNCTION_GET_KEYWORD_QUALIFIER_out(x) x | |
331 # define BOOST_PARAMETETER_FUNCTION_GET_KEYWORD_QUALIFIER_in_out(x) x | |
332 # define BOOST_PARAMETER_FUNCTION_KEYWORD_GET(x) \ | |
333 BOOST_PP_CAT(BOOST_PARAMETETER_FUNCTION_GET_KEYWORD_QUALIFIER_, x) | |
334 /**/ | |
335 | |
336 // Returns the keyword of x, where x is either a keyword qualifier | |
337 // or a keyword. | |
338 // | |
339 // k => k | |
340 // out(k) => k | |
341 // in_out(k) => k | |
342 // | |
343 # define BOOST_PARAMETER_FUNCTION_KEYWORD(x) \ | |
344 BOOST_PP_IF( \ | |
345 BOOST_PARAMETER_FUNCTION_IS_KEYWORD_QUALIFIER(x) \ | |
346 , BOOST_PARAMETER_FUNCTION_KEYWORD_GET \ | |
347 , x BOOST_PP_TUPLE_EAT(1) \ | |
348 )(x) | |
349 /**/ | |
350 | |
351 # define BOOST_PARAMETER_FN_ARG_KEYWORD(x) \ | |
352 BOOST_PARAMETER_FUNCTION_KEYWORD( \ | |
353 BOOST_PARAMETER_FN_ARG_NAME(x) \ | |
354 ) | |
355 | |
356 // Builds forwarding functions. | |
357 | |
358 # define BOOST_PARAMETER_FUNCTION_FWD_FUNCTION_TEMPLATE_Z(z, n) \ | |
359 template<BOOST_PP_ENUM_PARAMS_Z(z, n, class ParameterArgumentType)> | |
360 /**/ | |
361 | |
362 # if ! defined(BOOST_NO_SFINAE) && ! BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x592)) | |
363 # define BOOST_PARAMETER_FUNCTION_FWD_MATCH_Z(z, name, parameters, n) \ | |
364 , typename boost::parameter::aux::match< \ | |
365 parameters, BOOST_PP_ENUM_PARAMS(n, ParameterArgumentType) \ | |
366 >::type = parameters() | |
367 # else | |
368 # define BOOST_PARAMETER_FUNCTION_FWD_MATCH_Z(z, name, parameters, n) | |
369 # endif | |
370 /**/ | |
371 | |
372 # define BOOST_PARAMETER_FUNCTION_PARAMETERS_NAME(base) \ | |
373 BOOST_PP_CAT( \ | |
374 boost_param_parameters_ \ | |
375 , BOOST_PP_CAT(__LINE__, BOOST_PARAMETER_MEMBER_FUNCTION_NAME(base)) \ | |
376 ) | |
377 | |
378 // Produce a name for a result type metafunction for the function | |
379 // named base | |
380 # define BOOST_PARAMETER_FUNCTION_RESULT_NAME(base) \ | |
381 BOOST_PP_CAT( \ | |
382 boost_param_result_ \ | |
383 , BOOST_PP_CAT(__LINE__,BOOST_PARAMETER_MEMBER_FUNCTION_NAME(base)) \ | |
384 ) | |
385 | |
386 // Can't do boost_param_impl_ ## basee because base might start with an underscore | |
387 // daniel: what? how is that relevant? the reason for using CAT() is to make sure | |
388 // base is expanded. i'm not sure we need to here, but it's more stable to do it. | |
389 # define BOOST_PARAMETER_IMPL(base) \ | |
390 BOOST_PP_CAT(boost_param_impl,BOOST_PARAMETER_MEMBER_FUNCTION_NAME(base)) | |
391 | |
392 # define BOOST_PARAMETER_FUNCTION_FWD_FUNCTION00(z, n, r, data, elem) \ | |
393 BOOST_PP_IF( \ | |
394 n \ | |
395 , BOOST_PARAMETER_FUNCTION_FWD_FUNCTION_TEMPLATE_Z, BOOST_PP_TUPLE_EAT(2) \ | |
396 )(z,n) \ | |
397 BOOST_PARAMETER_MEMBER_FUNCTION_STATIC(BOOST_PP_TUPLE_ELEM(7,3,data)) \ | |
398 inline \ | |
399 BOOST_PP_EXPR_IF(n, typename) \ | |
400 BOOST_PARAMETER_FUNCTION_RESULT_NAME(BOOST_PP_TUPLE_ELEM(7,3,data))< \ | |
401 BOOST_PP_EXPR_IF(n, typename) \ | |
402 boost::parameter::aux::argument_pack< \ | |
403 BOOST_PARAMETER_FUNCTION_PARAMETERS_NAME(BOOST_PP_TUPLE_ELEM(7,3,data)) \ | |
404 BOOST_PP_COMMA_IF(n) \ | |
405 BOOST_PP_IF( \ | |
406 n, BOOST_PP_SEQ_ENUM, BOOST_PP_TUPLE_EAT(1) \ | |
407 )(elem) \ | |
408 >::type \ | |
409 >::type \ | |
410 BOOST_PARAMETER_MEMBER_FUNCTION_NAME(BOOST_PP_TUPLE_ELEM(7,3,data))( \ | |
411 BOOST_PP_IF( \ | |
412 n \ | |
413 , BOOST_PP_SEQ_FOR_EACH_I_R \ | |
414 , BOOST_PP_TUPLE_EAT(4) \ | |
415 )( \ | |
416 r \ | |
417 , BOOST_PARAMETER_FUNCTION_ARGUMENT \ | |
418 , ~ \ | |
419 , elem \ | |
420 ) \ | |
421 BOOST_PP_IF(n, BOOST_PARAMETER_FUNCTION_FWD_MATCH_Z, BOOST_PP_TUPLE_EAT(4))( \ | |
422 z \ | |
423 , BOOST_PP_TUPLE_ELEM(7,3,data) \ | |
424 , BOOST_PARAMETER_FUNCTION_PARAMETERS_NAME(BOOST_PP_TUPLE_ELEM(7,3,data)) \ | |
425 , n \ | |
426 ) \ | |
427 ) BOOST_PP_EXPR_IF(BOOST_PP_TUPLE_ELEM(7,4,data), const) \ | |
428 { \ | |
429 return BOOST_PARAMETER_IMPL(BOOST_PP_TUPLE_ELEM(7,3,data))( \ | |
430 BOOST_PARAMETER_FUNCTION_PARAMETERS_NAME(BOOST_PP_TUPLE_ELEM(7,3,data))()( \ | |
431 BOOST_PP_ENUM_PARAMS_Z(z, n, a) \ | |
432 ) \ | |
433 ); \ | |
434 } | |
435 /**/ | |
436 | |
437 # define BOOST_PARAMETER_FUNCTION_FWD_FUNCTION0(r, data, elem) \ | |
438 BOOST_PARAMETER_FUNCTION_FWD_FUNCTION00( \ | |
439 BOOST_PP_TUPLE_ELEM(7,0,data) \ | |
440 , BOOST_PP_TUPLE_ELEM(7,1,data) \ | |
441 , r \ | |
442 , data \ | |
443 , elem \ | |
444 ) | |
445 /**/ | |
446 | |
447 # define BOOST_PARAMETER_FUNCTION_FWD_FUNCTION_ARITY_0(z, n, data) \ | |
448 BOOST_PARAMETER_FUNCTION_FWD_FUNCTION00( \ | |
449 z, n, BOOST_PP_DEDUCE_R() \ | |
450 , (z, n, BOOST_PP_TUPLE_REM(5) data) \ | |
451 , ~ \ | |
452 ) | |
453 /**/ | |
454 | |
455 # define BOOST_PARAMETER_FUNCTION_FWD_FUNCTION_ARITY_N(z, n, data) \ | |
456 BOOST_PP_SEQ_FOR_EACH( \ | |
457 BOOST_PARAMETER_FUNCTION_FWD_FUNCTION0 \ | |
458 , (z, n, BOOST_PP_TUPLE_REM(5) data) \ | |
459 , BOOST_PP_SEQ_FOR_EACH_PRODUCT( \ | |
460 BOOST_PARAMETER_FUNCTION_FWD_PRODUCT \ | |
461 , BOOST_PP_SEQ_FIRST_N( \ | |
462 n, BOOST_PP_TUPLE_ELEM(5,3,data) \ | |
463 ) \ | |
464 ) \ | |
465 ) | |
466 /**/ | |
467 | |
468 # define BOOST_PARAMETER_FUNCTION_FWD_FUNCTION(z, n, data) \ | |
469 BOOST_PP_IF( \ | |
470 n \ | |
471 , BOOST_PARAMETER_FUNCTION_FWD_FUNCTION_ARITY_N \ | |
472 , BOOST_PARAMETER_FUNCTION_FWD_FUNCTION_ARITY_0 \ | |
473 )(z,n,data) \ | |
474 /**/ | |
475 | |
476 # define BOOST_PARAMETER_FUNCTION_FWD_FUNCTIONS0( \ | |
477 result,name,args,const_,combinations,range \ | |
478 ) \ | |
479 BOOST_PP_REPEAT_FROM_TO( \ | |
480 BOOST_PP_TUPLE_ELEM(2,0,range), BOOST_PP_TUPLE_ELEM(2,1,range) \ | |
481 , BOOST_PARAMETER_FUNCTION_FWD_FUNCTION \ | |
482 , (result,name,const_,combinations,BOOST_PP_TUPLE_ELEM(2,1,range)) \ | |
483 ) | |
484 /**/ | |
485 | |
486 # define BOOST_PARAMETER_FUNCTION_FWD_FUNCTIONS(result,name,args, const_, combinations) \ | |
487 BOOST_PARAMETER_FUNCTION_FWD_FUNCTIONS0( \ | |
488 result, name, args, const_, combinations, BOOST_PARAMETER_ARITY_RANGE(args) \ | |
489 ) | |
490 /**/ | |
491 | |
492 // Builds boost::parameter::parameters<> specialization | |
493 # define BOOST_PARAMETER_FUNCTION_PARAMETERS_QUALIFIER_optional(tag) \ | |
494 optional<tag | |
495 | |
496 # define BOOST_PARAMETER_FUNCTION_PARAMETERS_QUALIFIER_required(tag) \ | |
497 required<tag | |
498 | |
499 # define BOOST_PARAMETER_FUNCTION_PARAMETERS_QUALIFIER_deduced_optional(tag) \ | |
500 optional<boost::parameter::deduced<tag> | |
501 | |
502 # define BOOST_PARAMETER_FUNCTION_PARAMETERS_QUALIFIER_deduced_required(tag) \ | |
503 required<boost::parameter::deduced<tag> | |
504 | |
505 # if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) && !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) | |
506 | |
507 # if BOOST_WORKAROUND(BOOST_MSVC, == 1300) | |
508 # define BOOST_PARAMETER_PREDICATE_TYPE(p) void*(*) (void* p) | |
509 # else | |
510 # define BOOST_PARAMETER_PREDICATE_TYPE(p) void p | |
511 # endif | |
512 | |
513 # define BOOST_PARAMETER_FUNCTION_PARAMETERS_M(r,tag_namespace,i,elem) \ | |
514 BOOST_PP_COMMA_IF(i) \ | |
515 boost::parameter::BOOST_PP_CAT( \ | |
516 BOOST_PARAMETER_FUNCTION_PARAMETERS_QUALIFIER_ \ | |
517 , BOOST_PARAMETER_FN_ARG_QUALIFIER(elem) \ | |
518 )( \ | |
519 tag_namespace::BOOST_PARAMETER_FUNCTION_KEYWORD( \ | |
520 BOOST_PARAMETER_FN_ARG_KEYWORD(elem) \ | |
521 ) \ | |
522 ) \ | |
523 , typename boost::parameter::aux::unwrap_predicate< \ | |
524 BOOST_PARAMETER_PREDICATE_TYPE(BOOST_PARAMETER_FN_ARG_PRED(elem)) \ | |
525 >::type \ | |
526 > | |
527 # elif BOOST_WORKAROUND(BOOST_MSVC, < 1300) | |
528 # define BOOST_PARAMETER_FUNCTION_PARAMETERS_M(r,tag_namespace,i,elem) \ | |
529 BOOST_PP_COMMA_IF(i) \ | |
530 boost::parameter::BOOST_PP_CAT( \ | |
531 BOOST_PARAMETER_FUNCTION_PARAMETERS_QUALIFIER_ \ | |
532 , BOOST_PARAMETER_FN_ARG_QUALIFIER(elem) \ | |
533 )( \ | |
534 tag_namespace::BOOST_PARAMETER_FUNCTION_KEYWORD( \ | |
535 BOOST_PARAMETER_FN_ARG_KEYWORD(elem) \ | |
536 ) \ | |
537 ) \ | |
538 , boost::parameter::aux::funptr_predicate< \ | |
539 void* BOOST_PARAMETER_FN_ARG_PRED(elem) \ | |
540 > \ | |
541 > | |
542 # elif BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) | |
543 # define BOOST_PARAMETER_FUNCTION_PARAMETERS_M(r,tag_namespace,i,elem) \ | |
544 BOOST_PP_COMMA_IF(i) \ | |
545 boost::parameter::BOOST_PP_CAT( \ | |
546 BOOST_PARAMETER_FUNCTION_PARAMETERS_QUALIFIER_ \ | |
547 , BOOST_PARAMETER_FN_ARG_QUALIFIER(elem) \ | |
548 )( \ | |
549 tag_namespace::BOOST_PARAMETER_FUNCTION_KEYWORD( \ | |
550 BOOST_PARAMETER_FN_ARG_KEYWORD(elem) \ | |
551 ) \ | |
552 ) \ | |
553 , boost::mpl::always<boost::mpl::true_> \ | |
554 > | |
555 # endif | |
556 | |
557 # define BOOST_PARAMETER_FUNCTION_PARAMETERS(tag_namespace, base, args) \ | |
558 template <class BoostParameterDummy> \ | |
559 struct BOOST_PP_CAT( \ | |
560 BOOST_PP_CAT(boost_param_params_, __LINE__) \ | |
561 , BOOST_PARAMETER_MEMBER_FUNCTION_NAME(base) \ | |
562 ) : boost::parameter::parameters< \ | |
563 BOOST_PP_SEQ_FOR_EACH_I( \ | |
564 BOOST_PARAMETER_FUNCTION_PARAMETERS_M, tag_namespace, args \ | |
565 ) \ | |
566 > \ | |
567 {}; \ | |
568 \ | |
569 typedef BOOST_PP_CAT( \ | |
570 BOOST_PP_CAT(boost_param_params_, __LINE__) \ | |
571 , BOOST_PARAMETER_MEMBER_FUNCTION_NAME(base) \ | |
572 )<int> | |
573 | |
574 // Defines result type metafunction | |
575 # define BOOST_PARAMETER_FUNCTION_RESULT_ARG(z, _, i, x) \ | |
576 BOOST_PP_COMMA_IF(i) class BOOST_PP_TUPLE_ELEM(3,1,x) | |
577 /**/ | |
578 | |
579 # define BOOST_PARAMETER_FUNCTION_RESULT_(result, name, args) \ | |
580 template <class Args> \ | |
581 struct BOOST_PARAMETER_FUNCTION_RESULT_NAME(name) \ | |
582 { \ | |
583 typedef typename BOOST_PARAMETER_PARENTHESIZED_TYPE(result) type; \ | |
584 }; | |
585 | |
586 # if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) | |
587 | |
588 # define BOOST_PARAMETER_FUNCTION_RESULT(result, name, args) \ | |
589 BOOST_PARAMETER_FUNCTION_RESULT_(result, name, args) \ | |
590 template <> \ | |
591 struct BOOST_PARAMETER_FUNCTION_RESULT_NAME(name)<int> \ | |
592 { typedef int type; }; | |
593 | |
594 # else | |
595 | |
596 # define BOOST_PARAMETER_FUNCTION_RESULT(result, name, args) \ | |
597 BOOST_PARAMETER_FUNCTION_RESULT_(result, name, args) | |
598 | |
599 # endif | |
600 | |
601 // Defines implementation function | |
602 # define BOOST_PARAMETER_FUNCTION_IMPL_HEAD(name) \ | |
603 template <class Args> \ | |
604 typename BOOST_PARAMETER_FUNCTION_RESULT_NAME(name)< \ | |
605 Args \ | |
606 >::type BOOST_PARAMETER_IMPL(name)(Args const& args) | |
607 | |
608 # define BOOST_PARAMETER_FUNCTION_IMPL_FWD(name) \ | |
609 BOOST_PARAMETER_FUNCTION_IMPL_HEAD(name); | |
610 /**/ | |
611 | |
612 # define BOOST_PARAMETER_FUNCTION_SPLIT_ARG_required(state, arg) \ | |
613 ( \ | |
614 BOOST_PP_INC(BOOST_PP_TUPLE_ELEM(4, 0, state)) \ | |
615 , BOOST_PP_SEQ_PUSH_BACK(BOOST_PP_TUPLE_ELEM(4, 1, state), arg) \ | |
616 , BOOST_PP_TUPLE_ELEM(4, 2, state) \ | |
617 , BOOST_PP_TUPLE_ELEM(4, 3, state) \ | |
618 ) | |
619 | |
620 # define BOOST_PARAMETER_FUNCTION_SPLIT_ARG_deduced_required(state, arg) \ | |
621 BOOST_PARAMETER_FUNCTION_SPLIT_ARG_required(state, arg) | |
622 | |
623 # define BOOST_PARAMETER_FUNCTION_SPLIT_ARG_optional(state, arg) \ | |
624 ( \ | |
625 BOOST_PP_TUPLE_ELEM(4, 0, state) \ | |
626 , BOOST_PP_TUPLE_ELEM(4, 1, state) \ | |
627 , BOOST_PP_INC(BOOST_PP_TUPLE_ELEM(4, 2, state)) \ | |
628 , BOOST_PP_SEQ_PUSH_BACK(BOOST_PP_TUPLE_ELEM(4, 3, state), arg) \ | |
629 ) | |
630 | |
631 # define BOOST_PARAMETER_FUNCTION_SPLIT_ARG_deduced_optional(state, arg) \ | |
632 BOOST_PARAMETER_FUNCTION_SPLIT_ARG_optional(state, arg) | |
633 | |
634 # define BOOST_PARAMETER_FUNCTION_SPLIT_ARG(s, state, arg) \ | |
635 BOOST_PP_CAT( \ | |
636 BOOST_PARAMETER_FUNCTION_SPLIT_ARG_ \ | |
637 , BOOST_PARAMETER_FN_ARG_QUALIFIER(arg) \ | |
638 )(state, arg) | |
639 | |
640 // Returns (required_count, required, optional_count, optionals) tuple | |
641 # define BOOST_PARAMETER_FUNCTION_SPLIT_ARGS(args) \ | |
642 BOOST_PP_SEQ_FOLD_LEFT( \ | |
643 BOOST_PARAMETER_FUNCTION_SPLIT_ARG \ | |
644 , (0,BOOST_PP_SEQ_NIL, 0,BOOST_PP_SEQ_NIL) \ | |
645 , args \ | |
646 ) | |
647 | |
648 # define BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION_ARG_NAME(keyword) \ | |
649 BOOST_PP_CAT(BOOST_PP_CAT(keyword,_),type) | |
650 | |
651 // Helpers used as parameters to BOOST_PARAMETER_FUNCTION_DEFAULT_ARGUMENTS. | |
652 # define BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION_TEMPLATE_ARG(r, _, arg) \ | |
653 , class BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION_ARG_NAME( \ | |
654 BOOST_PARAMETER_FN_ARG_KEYWORD(arg) \ | |
655 ) | |
656 | |
657 # define BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION_ARG(r, _, arg) \ | |
658 , BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION_ARG_NAME( \ | |
659 BOOST_PARAMETER_FN_ARG_KEYWORD(arg) \ | |
660 )& BOOST_PARAMETER_FN_ARG_KEYWORD(arg) | |
661 | |
662 # define BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION_PARAMETER(r, _, arg) \ | |
663 , BOOST_PARAMETER_FN_ARG_KEYWORD(arg) | |
664 | |
665 // Produces a name for the dispatch functions. | |
666 # define BOOST_PARAMETER_FUNCTION_DEFAULT_NAME(name) \ | |
667 BOOST_PP_CAT( \ | |
668 boost_param_default_ \ | |
669 , BOOST_PP_CAT(__LINE__, BOOST_PARAMETER_MEMBER_FUNCTION_NAME(name)) \ | |
670 ) | |
671 | |
672 // Helper macro used below to produce lists based on the keyword argument | |
673 // names. macro is applied to every element. n is the number of | |
674 // optional arguments that should be included. | |
675 # define BOOST_PARAMETER_FUNCTION_DEFAULT_ARGUMENTS(macro, n, split_args) \ | |
676 BOOST_PP_SEQ_FOR_EACH( \ | |
677 macro \ | |
678 , ~ \ | |
679 , BOOST_PP_TUPLE_ELEM(4,1,split_args) \ | |
680 ) \ | |
681 BOOST_PP_SEQ_FOR_EACH( \ | |
682 macro \ | |
683 , ~ \ | |
684 , BOOST_PP_SEQ_FIRST_N( \ | |
685 BOOST_PP_SUB(BOOST_PP_TUPLE_ELEM(4,2,split_args), n) \ | |
686 , BOOST_PP_TUPLE_ELEM(4,3,split_args) \ | |
687 ) \ | |
688 ) | |
689 | |
690 // Generates a keyword | default expression. | |
691 # define BOOST_PARAMETER_FUNCTION_DEFAULT_EVAL_DEFAULT(arg, tag_namespace) \ | |
692 boost::parameter::keyword< \ | |
693 tag_namespace::BOOST_PARAMETER_FN_ARG_KEYWORD(arg) \ | |
694 >::instance | boost::parameter::aux::use_default_tag() | |
695 | |
696 # define BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION_GET_ARG(arg, tag_ns) \ | |
697 BOOST_PARAMETER_FUNCTION_CAST( \ | |
698 args[ \ | |
699 BOOST_PARAMETER_FUNCTION_DEFAULT_EVAL_DEFAULT( \ | |
700 arg, tag_ns \ | |
701 ) \ | |
702 ] \ | |
703 , BOOST_PARAMETER_FN_ARG_PRED(arg) \ | |
704 , Args \ | |
705 ) | |
706 | |
707 # define BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION_BODY(name, n, split_args, tag_namespace) \ | |
708 { \ | |
709 return BOOST_PARAMETER_FUNCTION_DEFAULT_NAME(name)( \ | |
710 (ResultType(*)())0 \ | |
711 , args \ | |
712 , 0L \ | |
713 BOOST_PARAMETER_FUNCTION_DEFAULT_ARGUMENTS( \ | |
714 BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION_PARAMETER \ | |
715 , n \ | |
716 , split_args \ | |
717 ) \ | |
718 , BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION_GET_ARG( \ | |
719 BOOST_PP_SEQ_ELEM( \ | |
720 BOOST_PP_SUB(BOOST_PP_TUPLE_ELEM(4,2,split_args), n) \ | |
721 , BOOST_PP_TUPLE_ELEM(4,3,split_args) \ | |
722 ) \ | |
723 , tag_namespace \ | |
724 ) \ | |
725 ); \ | |
726 } | |
727 | |
728 # define BOOST_PARAMETER_FUNCTION_DEFAULT_EVAL_ACTUAL_DEFAULT(arg) \ | |
729 BOOST_PARAMETER_FUNCTION_CAST( \ | |
730 boost::parameter::aux::as_lvalue(BOOST_PARAMETER_FN_ARG_DEFAULT(arg), 0L) \ | |
731 , BOOST_PARAMETER_FN_ARG_PRED(arg) \ | |
732 , Args \ | |
733 ) | |
734 | |
735 # define BOOST_PARAMETER_FUNCTION_DEFAULT_EVAL_DEFAULT_BODY(name, n, split_args, tag_ns, const_) \ | |
736 template < \ | |
737 class ResultType \ | |
738 , class Args \ | |
739 BOOST_PARAMETER_FUNCTION_DEFAULT_ARGUMENTS( \ | |
740 BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION_TEMPLATE_ARG \ | |
741 , BOOST_PP_INC(n) \ | |
742 , split_args \ | |
743 ) \ | |
744 > \ | |
745 BOOST_PARAMETER_MEMBER_FUNCTION_STATIC(name) \ | |
746 ResultType BOOST_PARAMETER_FUNCTION_DEFAULT_NAME(name)( \ | |
747 ResultType(*)() \ | |
748 , Args const& args \ | |
749 , long \ | |
750 BOOST_PARAMETER_FUNCTION_DEFAULT_ARGUMENTS( \ | |
751 BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION_ARG \ | |
752 , BOOST_PP_INC(n) \ | |
753 , split_args \ | |
754 ) \ | |
755 , boost::parameter::aux::use_default_tag \ | |
756 ) BOOST_PP_EXPR_IF(const_, const) \ | |
757 { \ | |
758 return BOOST_PARAMETER_FUNCTION_DEFAULT_NAME(name)( \ | |
759 (ResultType(*)())0 \ | |
760 , args \ | |
761 , 0L \ | |
762 BOOST_PARAMETER_FUNCTION_DEFAULT_ARGUMENTS( \ | |
763 BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION_PARAMETER \ | |
764 , BOOST_PP_INC(n) \ | |
765 , split_args \ | |
766 ) \ | |
767 , BOOST_PARAMETER_FUNCTION_DEFAULT_EVAL_ACTUAL_DEFAULT( \ | |
768 BOOST_PP_SEQ_ELEM( \ | |
769 BOOST_PP_SUB(BOOST_PP_TUPLE_ELEM(4,2,split_args), BOOST_PP_INC(n)) \ | |
770 , BOOST_PP_TUPLE_ELEM(4,3,split_args) \ | |
771 ) \ | |
772 ) \ | |
773 ); \ | |
774 } | |
775 | |
776 // Produces a forwarding layer in the default evaluation machine. | |
777 // | |
778 // data is a tuple: | |
779 // | |
780 // (name, split_args) | |
781 // | |
782 // Where name is the base name of the function, and split_args is a tuple: | |
783 // | |
784 // (required_count, required_args, optional_count, required_args) | |
785 // | |
786 | |
787 | |
788 // defines the actual function body for BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION below. | |
789 # define BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION0(z, n, data) \ | |
790 template < \ | |
791 class ResultType \ | |
792 , class Args \ | |
793 BOOST_PARAMETER_FUNCTION_DEFAULT_ARGUMENTS( \ | |
794 BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION_TEMPLATE_ARG \ | |
795 , n \ | |
796 , BOOST_PP_TUPLE_ELEM(5,1,data) \ | |
797 ) \ | |
798 > \ | |
799 BOOST_PARAMETER_MEMBER_FUNCTION_STATIC(BOOST_PP_TUPLE_ELEM(5,0,data)) \ | |
800 ResultType BOOST_PARAMETER_FUNCTION_DEFAULT_NAME(BOOST_PP_TUPLE_ELEM(5,0,data))( \ | |
801 ResultType(*)() \ | |
802 , Args const& args \ | |
803 , int \ | |
804 BOOST_PARAMETER_FUNCTION_DEFAULT_ARGUMENTS( \ | |
805 BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION_ARG \ | |
806 , n \ | |
807 , BOOST_PP_TUPLE_ELEM(5,1,data) \ | |
808 ) \ | |
809 ) BOOST_PP_EXPR_IF(BOOST_PP_TUPLE_ELEM(5,2,data), const) \ | |
810 BOOST_PP_IF( \ | |
811 n \ | |
812 , BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION_BODY \ | |
813 , ; BOOST_PP_TUPLE_EAT(4) \ | |
814 )( \ | |
815 BOOST_PP_TUPLE_ELEM(5,0,data) \ | |
816 , n \ | |
817 , BOOST_PP_TUPLE_ELEM(5,1,data) \ | |
818 , BOOST_PP_TUPLE_ELEM(5,3,data) \ | |
819 ) | |
820 | |
821 # define BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION(z, n, data) \ | |
822 BOOST_PP_IF( \ | |
823 BOOST_PP_AND( \ | |
824 BOOST_PP_NOT(n) \ | |
825 , BOOST_PP_TUPLE_ELEM(5,4,data) \ | |
826 ) \ | |
827 , BOOST_PP_TUPLE_EAT(3) \ | |
828 , BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION0 \ | |
829 )(z, n, data) \ | |
830 BOOST_PP_IF( \ | |
831 BOOST_PP_EQUAL(n, BOOST_PP_TUPLE_ELEM(4,2,BOOST_PP_TUPLE_ELEM(5,1,data))) \ | |
832 , BOOST_PP_TUPLE_EAT(5) \ | |
833 , BOOST_PARAMETER_FUNCTION_DEFAULT_EVAL_DEFAULT_BODY \ | |
834 )( \ | |
835 BOOST_PP_TUPLE_ELEM(5,0,data) \ | |
836 , n \ | |
837 , BOOST_PP_TUPLE_ELEM(5,1,data) \ | |
838 , BOOST_PP_TUPLE_ELEM(5,3,data) \ | |
839 , BOOST_PP_TUPLE_ELEM(5,2,data) \ | |
840 ) | |
841 | |
842 # define BOOST_PARAMETER_FUNCTION_DEFAULT_GET_ARG(r, tag_ns, arg) \ | |
843 , BOOST_PARAMETER_FUNCTION_CAST( \ | |
844 args[ \ | |
845 boost::parameter::keyword<tag_ns::BOOST_PARAMETER_FN_ARG_KEYWORD(arg)>::instance \ | |
846 ] \ | |
847 , BOOST_PARAMETER_FN_ARG_PRED(arg) \ | |
848 , Args \ | |
849 ) | |
850 | |
851 // Generates the function template that recives a ArgumentPack, and then | |
852 // goes on to call the layers of overloads generated by | |
853 // BOOST_PARAMETER_FUNCTION_DEFAULT_LAYER. | |
854 # define BOOST_PARAMETER_FUNCTION_INITIAL_DISPATCH_FUNCTION(name, split_args, const_, tag_ns) \ | |
855 template <class Args> \ | |
856 typename BOOST_PARAMETER_FUNCTION_RESULT_NAME(name)<Args>::type \ | |
857 BOOST_PARAMETER_MEMBER_FUNCTION_STATIC(name) \ | |
858 BOOST_PARAMETER_IMPL(name)(Args const& args) BOOST_PP_EXPR_IF(const_, const) \ | |
859 { \ | |
860 return BOOST_PARAMETER_FUNCTION_DEFAULT_NAME(name)( \ | |
861 (typename BOOST_PARAMETER_FUNCTION_RESULT_NAME(name)<Args>::type(*)())0 \ | |
862 , args \ | |
863 , 0L \ | |
864 \ | |
865 BOOST_PP_SEQ_FOR_EACH( \ | |
866 BOOST_PARAMETER_FUNCTION_DEFAULT_GET_ARG \ | |
867 , tag_ns \ | |
868 , BOOST_PP_TUPLE_ELEM(4,1,split_args) \ | |
869 ) \ | |
870 \ | |
871 ); \ | |
872 } | |
873 | |
874 // Helper for BOOST_PARAMETER_FUNCTION_DEFAULT_LAYER below. | |
875 # define BOOST_PARAMETER_FUNCTION_DEFAULT_LAYER_AUX( \ | |
876 name, split_args, skip_fwd_decl, const_, tag_namespace \ | |
877 ) \ | |
878 BOOST_PP_REPEAT_FROM_TO( \ | |
879 0 \ | |
880 , BOOST_PP_INC(BOOST_PP_TUPLE_ELEM(4, 2, split_args)) \ | |
881 , BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION \ | |
882 , (name, split_args, const_, tag_namespace, skip_fwd_decl) \ | |
883 ) \ | |
884 \ | |
885 BOOST_PARAMETER_FUNCTION_INITIAL_DISPATCH_FUNCTION(name, split_args, const_, tag_namespace) \ | |
886 \ | |
887 template < \ | |
888 class ResultType \ | |
889 , class Args \ | |
890 BOOST_PARAMETER_FUNCTION_DEFAULT_ARGUMENTS( \ | |
891 BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION_TEMPLATE_ARG \ | |
892 , 0 \ | |
893 , split_args \ | |
894 ) \ | |
895 > \ | |
896 BOOST_PARAMETER_MEMBER_FUNCTION_STATIC(name) \ | |
897 ResultType BOOST_PARAMETER_FUNCTION_DEFAULT_NAME(name)( \ | |
898 ResultType(*)() \ | |
899 , Args const& args \ | |
900 , int \ | |
901 BOOST_PARAMETER_FUNCTION_DEFAULT_ARGUMENTS( \ | |
902 BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION_ARG \ | |
903 , 0 \ | |
904 , split_args \ | |
905 ) \ | |
906 ) BOOST_PP_EXPR_IF(const_, const) | |
907 | |
908 // Generates a bunch of forwarding functions that each extract | |
909 // one more argument. | |
910 # define BOOST_PARAMETER_FUNCTION_DEFAULT_LAYER(name, args, skip_fwd_decl, const_, tag_ns) \ | |
911 BOOST_PARAMETER_FUNCTION_DEFAULT_LAYER_AUX( \ | |
912 name, BOOST_PARAMETER_FUNCTION_SPLIT_ARGS(args), skip_fwd_decl, const_, tag_ns \ | |
913 ) | |
914 /**/ | |
915 | |
916 // Defines the result metafunction and the parameters specialization. | |
917 # define BOOST_PARAMETER_FUNCTION_HEAD(result, name, tag_namespace, args) \ | |
918 BOOST_PARAMETER_FUNCTION_RESULT(result, name, args) \ | |
919 \ | |
920 BOOST_PARAMETER_FUNCTION_PARAMETERS(tag_namespace, name, args) \ | |
921 BOOST_PARAMETER_FUNCTION_PARAMETERS_NAME(name); \ | |
922 | |
923 // Helper for BOOST_PARAMETER_FUNCTION below. | |
924 # define BOOST_PARAMETER_FUNCTION_AUX(result, name, tag_namespace, args) \ | |
925 BOOST_PARAMETER_FUNCTION_HEAD(result, name, tag_namespace, args) \ | |
926 BOOST_PARAMETER_FUNCTION_IMPL_HEAD(name); \ | |
927 \ | |
928 BOOST_PARAMETER_FUNCTION_FWD_FUNCTIONS( \ | |
929 result, name, args, 0 \ | |
930 , BOOST_PARAMETER_FUNCTION_FWD_COMBINATIONS(args) \ | |
931 ) \ | |
932 \ | |
933 BOOST_PARAMETER_FUNCTION_DEFAULT_LAYER(name, args, 0, 0, tag_namespace) | |
934 | |
935 // Defines a Boost.Parameter enabled function with the new syntax. | |
936 # define BOOST_PARAMETER_FUNCTION(result, name, tag_namespace, args) \ | |
937 BOOST_PARAMETER_FUNCTION_AUX( \ | |
938 result, name, tag_namespace \ | |
939 , BOOST_PARAMETER_FLATTEN(3, 2, 3, args) \ | |
940 ) \ | |
941 /**/ | |
942 | |
943 // Defines a Boost.Parameter enabled function. | |
944 # define BOOST_PARAMETER_BASIC_FUNCTION_AUX(result, name, tag_namespace, args) \ | |
945 BOOST_PARAMETER_FUNCTION_HEAD(result, name, tag_namespace, args) \ | |
946 \ | |
947 BOOST_PARAMETER_FUNCTION_IMPL_FWD(name) \ | |
948 \ | |
949 BOOST_PARAMETER_FUNCTION_FWD_FUNCTIONS( \ | |
950 result, name, args, 0 \ | |
951 , BOOST_PARAMETER_FUNCTION_FWD_COMBINATIONS(args) \ | |
952 ) \ | |
953 \ | |
954 BOOST_PARAMETER_FUNCTION_IMPL_HEAD(name) | |
955 | |
956 # define BOOST_PARAMETER_BASIC_FUNCTION(result, name, tag_namespace, args) \ | |
957 BOOST_PARAMETER_BASIC_FUNCTION_AUX( \ | |
958 result, name, tag_namespace \ | |
959 , BOOST_PARAMETER_FLATTEN(2, 2, 3, args) \ | |
960 ) \ | |
961 /**/ | |
962 | |
963 // Defines a Boost.Parameter enabled member function. | |
964 # define BOOST_PARAMETER_BASIC_MEMBER_FUNCTION_AUX(result, name, tag_namespace, args, const_) \ | |
965 BOOST_PARAMETER_FUNCTION_HEAD(result, name, tag_namespace, args) \ | |
966 \ | |
967 BOOST_PARAMETER_FUNCTION_FWD_FUNCTIONS( \ | |
968 result, name, args, const_ \ | |
969 , BOOST_PARAMETER_FUNCTION_FWD_COMBINATIONS(args) \ | |
970 ) \ | |
971 \ | |
972 BOOST_PARAMETER_FUNCTION_IMPL_HEAD(name) BOOST_PP_EXPR_IF(const_, const) \ | |
973 /**/ | |
974 | |
975 # define BOOST_PARAMETER_BASIC_MEMBER_FUNCTION(result, name, tag_namespace, args) \ | |
976 BOOST_PARAMETER_BASIC_MEMBER_FUNCTION_AUX( \ | |
977 result, name, tag_namespace \ | |
978 , BOOST_PARAMETER_FLATTEN(2, 2, 3, args) \ | |
979 , 0 \ | |
980 ) | |
981 /**/ | |
982 | |
983 # define BOOST_PARAMETER_BASIC_CONST_MEMBER_FUNCTION(result, name, tag_namespace, args) \ | |
984 BOOST_PARAMETER_BASIC_MEMBER_FUNCTION_AUX( \ | |
985 result, name, tag_namespace \ | |
986 , BOOST_PARAMETER_FLATTEN(2, 2, 3, args) \ | |
987 , 1 \ | |
988 ) | |
989 /**/ | |
990 | |
991 | |
992 | |
993 # define BOOST_PARAMETER_MEMBER_FUNCTION_AUX(result, name, tag_namespace, const_, args) \ | |
994 BOOST_PARAMETER_FUNCTION_HEAD(result, name, tag_namespace, args) \ | |
995 \ | |
996 BOOST_PARAMETER_FUNCTION_FWD_FUNCTIONS( \ | |
997 result, name, args, const_ \ | |
998 , BOOST_PARAMETER_FUNCTION_FWD_COMBINATIONS(args) \ | |
999 ) \ | |
1000 \ | |
1001 BOOST_PARAMETER_FUNCTION_DEFAULT_LAYER(name, args, 1, const_, tag_namespace) | |
1002 | |
1003 // Defines a Boost.Parameter enabled function with the new syntax. | |
1004 # define BOOST_PARAMETER_MEMBER_FUNCTION(result, name, tag_namespace, args) \ | |
1005 BOOST_PARAMETER_MEMBER_FUNCTION_AUX( \ | |
1006 result, name, tag_namespace, 0 \ | |
1007 , BOOST_PARAMETER_FLATTEN(3, 2, 3, args) \ | |
1008 ) \ | |
1009 /**/ | |
1010 | |
1011 # define BOOST_PARAMETER_CONST_MEMBER_FUNCTION(result, name, tag_namespace, args) \ | |
1012 BOOST_PARAMETER_MEMBER_FUNCTION_AUX( \ | |
1013 result, name, tag_namespace, 1 \ | |
1014 , BOOST_PARAMETER_FLATTEN(3, 2, 3, args) \ | |
1015 ) \ | |
1016 /**/ | |
1017 | |
1018 // Defines a Boost.Parameter enabled constructor. | |
1019 | |
1020 # define BOOST_PARAMETER_FUNCTION_ARGUMENT(r, _, i, elem) \ | |
1021 BOOST_PP_COMMA_IF(i) elem& BOOST_PP_CAT(a, i) | |
1022 /**/ | |
1023 | |
1024 # if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) | |
1025 | |
1026 // Older MSVC can't do what's necessary to handle commas in base names; just | |
1027 // use a typedef instead if you have a base name that contains commas. | |
1028 # define BOOST_PARAMETER_PARENTHESIZED_BASE(x) BOOST_PP_SEQ_HEAD(x) | |
1029 | |
1030 # else | |
1031 | |
1032 # define BOOST_PARAMETER_PARENTHESIZED_BASE(x) BOOST_PARAMETER_PARENTHESIZED_TYPE(x) | |
1033 | |
1034 # endif | |
1035 | |
1036 # define BOOST_PARAMETER_FUNCTION_FWD_CONSTRUCTOR00(z, n, r, data, elem) \ | |
1037 BOOST_PP_IF( \ | |
1038 n \ | |
1039 , BOOST_PARAMETER_FUNCTION_FWD_FUNCTION_TEMPLATE_Z, BOOST_PP_TUPLE_EAT(2) \ | |
1040 )(z, n) \ | |
1041 BOOST_PP_EXPR_IF(BOOST_PP_EQUAL(n,1), explicit) \ | |
1042 BOOST_PP_TUPLE_ELEM(6,2,data)( \ | |
1043 BOOST_PP_IF( \ | |
1044 n \ | |
1045 , BOOST_PP_SEQ_FOR_EACH_I_R \ | |
1046 , BOOST_PP_TUPLE_EAT(4) \ | |
1047 )( \ | |
1048 r \ | |
1049 , BOOST_PARAMETER_FUNCTION_ARGUMENT \ | |
1050 , ~ \ | |
1051 , elem \ | |
1052 ) \ | |
1053 BOOST_PP_IF(n, BOOST_PARAMETER_FUNCTION_FWD_MATCH_Z, BOOST_PP_TUPLE_EAT(4))( \ | |
1054 z \ | |
1055 , BOOST_PP_TUPLE_ELEM(6,3,data) \ | |
1056 , BOOST_PP_CAT(constructor_parameters, __LINE__) \ | |
1057 , n \ | |
1058 ) \ | |
1059 ) \ | |
1060 : BOOST_PARAMETER_PARENTHESIZED_BASE(BOOST_PP_TUPLE_ELEM(6,3,data)) ( \ | |
1061 BOOST_PP_CAT(constructor_parameters, __LINE__)()( \ | |
1062 BOOST_PP_ENUM_PARAMS_Z(z, n, a) \ | |
1063 ) \ | |
1064 ) \ | |
1065 {} | |
1066 /**/ | |
1067 | |
1068 # define BOOST_PARAMETER_FUNCTION_FWD_CONSTRUCTOR0(r, data, elem) \ | |
1069 BOOST_PARAMETER_FUNCTION_FWD_CONSTRUCTOR00( \ | |
1070 BOOST_PP_TUPLE_ELEM(6,0,data) \ | |
1071 , BOOST_PP_TUPLE_ELEM(6,1,data) \ | |
1072 , r \ | |
1073 , data \ | |
1074 , elem \ | |
1075 ) | |
1076 /**/ | |
1077 | |
1078 # define BOOST_PARAMETER_FUNCTION_FWD_PRODUCT(r, product) \ | |
1079 (product) | |
1080 /**/ | |
1081 | |
1082 # define BOOST_PARAMETER_FUNCTION_FWD_CONSTRUCTOR_ARITY_0(z, n, data) \ | |
1083 BOOST_PARAMETER_FUNCTION_FWD_CONSTRUCTOR00( \ | |
1084 z, n, BOOST_PP_DEDUCE_R() \ | |
1085 , (z, n, BOOST_PP_TUPLE_REM(4) data) \ | |
1086 , ~ \ | |
1087 ) | |
1088 /**/ | |
1089 | |
1090 # define BOOST_PARAMETER_FUNCTION_FWD_CONSTRUCTOR_ARITY_N(z, n, data) \ | |
1091 BOOST_PP_SEQ_FOR_EACH( \ | |
1092 BOOST_PARAMETER_FUNCTION_FWD_CONSTRUCTOR0 \ | |
1093 , (z, n, BOOST_PP_TUPLE_REM(4) data) \ | |
1094 , BOOST_PP_SEQ_FOR_EACH_PRODUCT( \ | |
1095 BOOST_PARAMETER_FUNCTION_FWD_PRODUCT \ | |
1096 , BOOST_PP_SEQ_FIRST_N( \ | |
1097 n, BOOST_PP_TUPLE_ELEM(4,2,data) \ | |
1098 ) \ | |
1099 ) \ | |
1100 ) | |
1101 /**/ | |
1102 | |
1103 # define BOOST_PARAMETER_FUNCTION_FWD_CONSTRUCTOR(z, n, data) \ | |
1104 BOOST_PP_IF( \ | |
1105 n \ | |
1106 , BOOST_PARAMETER_FUNCTION_FWD_CONSTRUCTOR_ARITY_N \ | |
1107 , BOOST_PARAMETER_FUNCTION_FWD_CONSTRUCTOR_ARITY_0 \ | |
1108 )(z,n,data) \ | |
1109 /**/ | |
1110 | |
1111 # define BOOST_PARAMETER_FUNCTION_FWD_CONSTRUCTORS0(class_,base,args,combinations,range) \ | |
1112 BOOST_PP_REPEAT_FROM_TO( \ | |
1113 BOOST_PP_TUPLE_ELEM(2,0,range), BOOST_PP_TUPLE_ELEM(2,1,range) \ | |
1114 , BOOST_PARAMETER_FUNCTION_FWD_CONSTRUCTOR \ | |
1115 , (class_,base,combinations,BOOST_PP_TUPLE_ELEM(2,1,range)) \ | |
1116 ) | |
1117 /**/ | |
1118 | |
1119 # define BOOST_PARAMETER_FUNCTION_FWD_CONSTRUCTORS(class_,base,args,combinations) \ | |
1120 BOOST_PARAMETER_FUNCTION_FWD_CONSTRUCTORS0( \ | |
1121 class_, base, args, combinations, BOOST_PARAMETER_ARITY_RANGE(args) \ | |
1122 ) | |
1123 /**/ | |
1124 | |
1125 # define BOOST_PARAMETER_CONSTRUCTOR_AUX(class_, base, tag_namespace, args) \ | |
1126 BOOST_PARAMETER_FUNCTION_PARAMETERS(tag_namespace, ctor, args) \ | |
1127 BOOST_PP_CAT(constructor_parameters, __LINE__); \ | |
1128 \ | |
1129 BOOST_PARAMETER_FUNCTION_FWD_CONSTRUCTORS( \ | |
1130 class_, base, args \ | |
1131 , BOOST_PARAMETER_FUNCTION_FWD_COMBINATIONS(args) \ | |
1132 ) \ | |
1133 /**/ | |
1134 | |
1135 # define BOOST_PARAMETER_CONSTRUCTOR(class_, base, tag_namespace, args) \ | |
1136 BOOST_PARAMETER_CONSTRUCTOR_AUX( \ | |
1137 class_, base, tag_namespace \ | |
1138 , BOOST_PARAMETER_FLATTEN(2, 2, 3, args) \ | |
1139 ) | |
1140 /**/ | |
1141 | |
1142 # ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING | |
1143 # define BOOST_PARAMETER_FUNCTION_FWD_COMBINATION(r, _, i, elem) \ | |
1144 (BOOST_PP_IF( \ | |
1145 BOOST_PARAMETER_FUNCTION_IS_KEYWORD_QUALIFIER( \ | |
1146 BOOST_PARAMETER_FN_ARG_NAME(elem) \ | |
1147 ) \ | |
1148 , (const ParameterArgumentType ## i)(ParameterArgumentType ## i) \ | |
1149 , (const ParameterArgumentType ## i) \ | |
1150 )) | |
1151 // MSVC6.5 lets us bind rvalues to T&. | |
1152 # elif BOOST_WORKAROUND(BOOST_MSVC, < 1300) | |
1153 # define BOOST_PARAMETER_FUNCTION_FWD_COMBINATION(r, _, i, elem) \ | |
1154 (BOOST_PP_IF( \ | |
1155 BOOST_PARAMETER_FUNCTION_IS_KEYWORD_QUALIFIER( \ | |
1156 BOOST_PARAMETER_FN_ARG_NAME(elem) \ | |
1157 ) \ | |
1158 , (ParameterArgumentType ## i) \ | |
1159 , (const ParameterArgumentType ## i) \ | |
1160 )) | |
1161 // No partial ordering. This feature doesn't work. | |
1162 // This is exactly the same as for VC6.5, but we might change it later. | |
1163 # else | |
1164 # define BOOST_PARAMETER_FUNCTION_FWD_COMBINATION(r, _, i, elem) \ | |
1165 (BOOST_PP_IF( \ | |
1166 BOOST_PARAMETER_FUNCTION_IS_KEYWORD_QUALIFIER( \ | |
1167 BOOST_PARAMETER_FN_ARG_NAME(elem) \ | |
1168 ) \ | |
1169 , (ParameterArgumentType ## i) \ | |
1170 , (const ParameterArgumentType ## i) \ | |
1171 )) | |
1172 # endif | |
1173 | |
1174 # define BOOST_PARAMETER_FUNCTION_FWD_COMBINATIONS(args) \ | |
1175 BOOST_PP_SEQ_FOR_EACH_I(BOOST_PARAMETER_FUNCTION_FWD_COMBINATION, ~, args) | |
1176 | |
1177 #endif // BOOST_PARAMETER_PREPROCESSOR_060206_HPP | |
1178 |