preprocessor.hpp 38 KB

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