Chris@16: // Copyright Daniel Wallin 2006. Use, modification and distribution is Chris@16: // subject to the Boost Software License, Version 1.0. (See accompanying Chris@16: // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) Chris@16: Chris@16: #ifndef BOOST_PARAMETER_PREPROCESSOR_060206_HPP Chris@16: # define BOOST_PARAMETER_PREPROCESSOR_060206_HPP Chris@16: Chris@16: # include Chris@16: # include Chris@16: # include Chris@16: Chris@16: # include Chris@16: # include Chris@16: # include Chris@16: Chris@16: # include Chris@16: # include Chris@16: # include Chris@16: # include Chris@16: # include Chris@16: # include Chris@16: # include Chris@16: # include Chris@16: # include Chris@16: # include Chris@16: # include Chris@16: # include Chris@16: # include Chris@16: # include Chris@16: # include Chris@16: # include Chris@16: # include Chris@16: # include Chris@16: Chris@16: # include Chris@16: Chris@16: # include Chris@16: # include Chris@16: Chris@16: # if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) Chris@16: # include Chris@16: # endif Chris@16: Chris@16: namespace boost { namespace parameter { namespace aux { Chris@16: Chris@16: # if ! defined(BOOST_NO_SFINAE) && ! BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x592)) Chris@16: Chris@16: // Given Match, which is "void x" where x is an argument matching Chris@16: // criterion, extract a corresponding MPL predicate. Chris@16: template Chris@16: struct unwrap_predicate; Chris@16: Chris@16: // Match anything Chris@16: template <> Chris@16: struct unwrap_predicate Chris@16: { Chris@16: typedef mpl::always type; Chris@16: }; Chris@16: Chris@16: #if BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x580)) Chris@16: Chris@16: typedef void* voidstar; Chris@16: Chris@16: // A matching predicate is explicitly specified Chris@16: template Chris@16: struct unwrap_predicate Chris@16: { Chris@16: typedef Predicate type; Chris@16: }; Chris@16: Chris@16: #else Chris@16: Chris@16: // A matching predicate is explicitly specified Chris@16: template Chris@16: struct unwrap_predicate Chris@16: { Chris@16: typedef Predicate type; Chris@16: }; Chris@16: Chris@16: #endif Chris@16: Chris@16: Chris@16: // A type to which the argument is supposed to be convertible is Chris@16: // specified Chris@16: template Chris@16: struct unwrap_predicate Chris@16: { Chris@16: typedef is_convertible type; Chris@16: }; Chris@16: Chris@16: // Recast the ParameterSpec's nested match metafunction as a free metafunction Chris@16: template < Chris@16: class Parameters Chris@16: , BOOST_PP_ENUM_BINARY_PARAMS( Chris@16: BOOST_PARAMETER_MAX_ARITY, class A, = boost::parameter::void_ BOOST_PP_INTERCEPT Chris@16: ) Chris@16: > Chris@16: struct match Chris@16: : Parameters::template match< Chris@16: BOOST_PP_ENUM_PARAMS(BOOST_PARAMETER_MAX_ARITY, A) Chris@16: > Chris@16: {}; Chris@16: # endif Chris@16: Chris@16: # if BOOST_WORKAROUND(BOOST_MSVC, == 1300) Chris@16: Chris@16: // Function template argument deduction does many of the same things Chris@16: // as type matching during partial specialization, so we call a Chris@16: // function template to "store" T into the type memory addressed by Chris@16: // void(*)(T). Chris@16: template Chris@16: msvc_store_type Chris@16: msvc_store_predicate_type(void*(*)(void**(T))); Chris@16: Chris@16: template Chris@16: msvc_store_type,void*(*)(void*(T))> Chris@16: msvc_store_predicate_type(void*(*)(void*(T))); Chris@16: Chris@16: template Chris@16: struct unwrap_predicate Chris@16: { Chris@16: static FunctionType f; Chris@16: Chris@16: // We don't want the function to be evaluated, just instantiated, Chris@16: // so protect it inside of sizeof. Chris@16: enum { dummy = sizeof(msvc_store_predicate_type(f)) }; Chris@16: Chris@16: // Now pull the type out of the instantiated base class Chris@16: typedef typename msvc_type_memory::storage::type type; Chris@16: }; Chris@16: Chris@16: template <> Chris@16: struct unwrap_predicate Chris@16: { Chris@16: typedef mpl::always type; Chris@16: }; Chris@16: Chris@16: # endif Chris@16: Chris@16: # undef false_ Chris@16: Chris@16: template < Chris@16: class Parameters Chris@16: , BOOST_PP_ENUM_BINARY_PARAMS( Chris@16: BOOST_PARAMETER_MAX_ARITY, class A, = boost::parameter::void_ BOOST_PP_INTERCEPT Chris@16: ) Chris@16: > Chris@16: struct argument_pack Chris@16: { Chris@16: typedef typename make_arg_list< Chris@16: typename BOOST_PARAMETER_build_arg_list( Chris@16: BOOST_PARAMETER_MAX_ARITY, make_items, typename Parameters::parameter_spec, A Chris@16: )::type Chris@16: , typename Parameters::deduced_list Chris@16: , tag_keyword_arg Chris@16: , mpl::false_ Chris@16: >::type result; Chris@16: typedef typename mpl::first::type type; Chris@16: }; Chris@16: Chris@16: # if 1 //BOOST_WORKAROUND(BOOST_MSVC, < 1300) Chris@16: // Works around VC6 problem where it won't accept rvalues. Chris@16: template Chris@16: T& as_lvalue(T& value, long) Chris@16: { Chris@16: return value; Chris@16: } Chris@16: Chris@16: template Chris@16: T const& as_lvalue(T const& value, int) Chris@16: { Chris@16: return value; Chris@16: } Chris@16: # endif Chris@16: Chris@16: Chris@16: # if BOOST_WORKAROUND(BOOST_MSVC, < 1300) \ Chris@16: || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) Chris@16: Chris@16: template Chris@16: struct apply_predicate Chris@16: { Chris@16: BOOST_MPL_ASSERT(( Chris@16: mpl::and_ Chris@16: )); Chris@16: Chris@16: typedef typename mpl::if_< Chris@16: typename mpl::apply2::type Chris@16: , char Chris@16: , int Chris@16: >::type type; Chris@16: }; Chris@16: Chris@16: template Chris@16: struct funptr_predicate Chris@16: { Chris@16: static P p; Chris@16: Chris@16: template Chris@16: static typename apply_predicate::type Chris@16: check_predicate(type, Args*, void**(*)(P0)); Chris@16: Chris@16: template Chris@16: static typename mpl::if_< Chris@16: is_convertible Chris@16: , char Chris@16: , int Chris@16: >::type check_predicate(type, Args*, void*(*)(P0)); Chris@16: Chris@16: template Chris@16: struct apply Chris@16: { Chris@16: BOOST_STATIC_CONSTANT(bool, result = Chris@16: sizeof(check_predicate(boost::type(), (Args*)0, &p)) == 1 Chris@16: ); Chris@16: Chris@16: typedef mpl::bool_::result> type; Chris@16: }; Chris@16: }; Chris@16: Chris@16: template <> Chris@16: struct funptr_predicate Chris@16: : mpl::always Chris@16: {}; Chris@16: Chris@16: # endif Chris@16: Chris@16: }}} // namespace boost::parameter::aux Chris@16: Chris@16: # if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) Chris@16: // From Paul Mensonides Chris@16: # define BOOST_PARAMETER_IS_NULLARY(x) \ Chris@16: BOOST_PP_SPLIT(1, BOOST_PARAMETER_IS_NULLARY_C x BOOST_PP_COMMA() 0) \ Chris@16: /**/ Chris@16: # define BOOST_PARAMETER_IS_NULLARY_C() \ Chris@16: ~, 1 BOOST_PP_RPAREN() \ Chris@16: BOOST_PP_TUPLE_EAT(2) BOOST_PP_LPAREN() ~ \ Chris@16: /**/ Chris@16: # else Chris@16: # define BOOST_PARAMETER_IS_NULLARY(x) BOOST_PP_IS_NULLARY(x) Chris@16: # endif Chris@16: Chris@16: # define BOOST_PARAMETER_MEMBER_FUNCTION_CHECK_STATIC_static () Chris@16: # define BOOST_PARAMETER_MEMBER_FUNCTION_IS_STATIC(name) \ Chris@16: BOOST_PARAMETER_IS_NULLARY( \ Chris@16: BOOST_PP_CAT(BOOST_PARAMETER_MEMBER_FUNCTION_CHECK_STATIC_,name) \ Chris@16: ) Chris@16: Chris@16: # if !defined(BOOST_MSVC) Chris@16: # define BOOST_PARAMETER_MEMBER_FUNCTION_STRIP_STATIC_static Chris@16: # define BOOST_PARAMETER_MEMBER_FUNCTION_STRIP_STATIC(name) \ Chris@16: BOOST_PP_CAT(BOOST_PARAMETER_MEMBER_FUNCTION_STRIP_STATIC_, name) Chris@16: # else Chris@16: // Workaround for MSVC preprocessor. Chris@16: // Chris@16: // When stripping static from "static f", msvc will produce Chris@16: // " f". The leading whitespace doesn't go away when pasting Chris@16: // the token with something else, so this thing is a hack to Chris@16: // strip the whitespace. Chris@16: # define BOOST_PARAMETER_MEMBER_FUNCTION_STRIP_STATIC_static ( Chris@16: # define BOOST_PARAMETER_MEMBER_FUNCTION_STRIP_STATIC_AUX(name) \ Chris@16: BOOST_PP_CAT(BOOST_PARAMETER_MEMBER_FUNCTION_STRIP_STATIC_, name)) Chris@16: # define BOOST_PARAMETER_MEMBER_FUNCTION_STRIP_STATIC(name) \ Chris@16: BOOST_PP_SEQ_HEAD( \ Chris@16: BOOST_PARAMETER_MEMBER_FUNCTION_STRIP_STATIC_AUX(name) \ Chris@16: ) Chris@16: # endif Chris@16: Chris@16: # define BOOST_PARAMETER_MEMBER_FUNCTION_STATIC(name) \ Chris@16: BOOST_PP_EXPR_IF( \ Chris@16: BOOST_PARAMETER_MEMBER_FUNCTION_IS_STATIC(name) \ Chris@16: , static \ Chris@16: ) Chris@16: Chris@16: # define BOOST_PARAMETER_MEMBER_FUNCTION_NAME(name) \ Chris@16: BOOST_PP_IF( \ Chris@16: BOOST_PARAMETER_MEMBER_FUNCTION_IS_STATIC(name) \ Chris@16: , BOOST_PARAMETER_MEMBER_FUNCTION_STRIP_STATIC \ Chris@16: , name BOOST_PP_TUPLE_EAT(1) \ Chris@16: )(name) Chris@16: Chris@16: // Calculates [begin, end) arity range. Chris@16: Chris@16: # define BOOST_PARAMETER_ARITY_RANGE_M_optional(state) state Chris@16: # define BOOST_PARAMETER_ARITY_RANGE_M_deduced_optional(state) state Chris@16: # define BOOST_PARAMETER_ARITY_RANGE_M_required(state) BOOST_PP_INC(state) Chris@16: # define BOOST_PARAMETER_ARITY_RANGE_M_deduced_required(state) BOOST_PP_INC(state) Chris@16: Chris@16: # define BOOST_PARAMETER_ARITY_RANGE_M(s, state, x) \ Chris@16: BOOST_PP_CAT( \ Chris@16: BOOST_PARAMETER_ARITY_RANGE_M_ \ Chris@16: , BOOST_PARAMETER_FN_ARG_QUALIFIER(x) \ Chris@16: )(state) Chris@16: /**/ Chris@16: Chris@16: # define BOOST_PARAMETER_ARITY_RANGE(args) \ Chris@16: ( \ Chris@16: BOOST_PP_SEQ_FOLD_LEFT(BOOST_PARAMETER_ARITY_RANGE_M, 0, args) \ Chris@16: , BOOST_PP_INC(BOOST_PP_SEQ_SIZE(args)) \ Chris@16: ) Chris@16: /**/ Chris@16: Chris@16: // Accessor macros for the argument specs tuple. Chris@16: # define BOOST_PARAMETER_FN_ARG_QUALIFIER(x) \ Chris@16: BOOST_PP_TUPLE_ELEM(4,0,x) Chris@16: /**/ Chris@16: Chris@16: # define BOOST_PARAMETER_FN_ARG_NAME(x) \ Chris@16: BOOST_PP_TUPLE_ELEM(4,1,x) Chris@16: /**/ Chris@16: Chris@16: # define BOOST_PARAMETER_FN_ARG_PRED(x) \ Chris@16: BOOST_PP_TUPLE_ELEM(4,2,x) Chris@16: /**/ Chris@16: Chris@16: # define BOOST_PARAMETER_FN_ARG_DEFAULT(x) \ Chris@16: BOOST_PP_TUPLE_ELEM(4,3,x) Chris@16: /**/ Chris@16: Chris@16: # define BOOST_PARAMETETER_FUNCTION_EAT_KEYWORD_QUALIFIER_out(x) Chris@16: # define BOOST_PARAMETETER_FUNCTION_EAT_KEYWORD_QUALIFIER_in_out(x) Chris@16: Chris@16: // Returns 1 if x is either "out(k)" or "in_out(k)". Chris@16: # define BOOST_PARAMETER_FUNCTION_IS_KEYWORD_QUALIFIER(x) \ Chris@16: BOOST_PP_IS_EMPTY( \ Chris@16: BOOST_PP_CAT(BOOST_PARAMETETER_FUNCTION_EAT_KEYWORD_QUALIFIER_, x) \ Chris@16: ) \ Chris@16: /**/ Chris@16: Chris@16: # define BOOST_PARAMETETER_FUNCTION_GET_KEYWORD_QUALIFIER_out(x) x Chris@16: # define BOOST_PARAMETETER_FUNCTION_GET_KEYWORD_QUALIFIER_in_out(x) x Chris@16: # define BOOST_PARAMETER_FUNCTION_KEYWORD_GET(x) \ Chris@16: BOOST_PP_CAT(BOOST_PARAMETETER_FUNCTION_GET_KEYWORD_QUALIFIER_, x) Chris@16: /**/ Chris@16: Chris@16: // Returns the keyword of x, where x is either a keyword qualifier Chris@16: // or a keyword. Chris@16: // Chris@16: // k => k Chris@16: // out(k) => k Chris@16: // in_out(k) => k Chris@16: // Chris@16: # define BOOST_PARAMETER_FUNCTION_KEYWORD(x) \ Chris@16: BOOST_PP_IF( \ Chris@16: BOOST_PARAMETER_FUNCTION_IS_KEYWORD_QUALIFIER(x) \ Chris@16: , BOOST_PARAMETER_FUNCTION_KEYWORD_GET \ Chris@16: , x BOOST_PP_TUPLE_EAT(1) \ Chris@16: )(x) Chris@16: /**/ Chris@16: Chris@16: # define BOOST_PARAMETER_FN_ARG_KEYWORD(x) \ Chris@16: BOOST_PARAMETER_FUNCTION_KEYWORD( \ Chris@16: BOOST_PARAMETER_FN_ARG_NAME(x) \ Chris@16: ) Chris@16: Chris@16: // Builds forwarding functions. Chris@16: Chris@16: # define BOOST_PARAMETER_FUNCTION_FWD_FUNCTION_TEMPLATE_Z(z, n) \ Chris@16: template Chris@16: /**/ Chris@16: Chris@16: # if ! defined(BOOST_NO_SFINAE) && ! BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x592)) Chris@16: # define BOOST_PARAMETER_FUNCTION_FWD_MATCH_Z(z, name, parameters, n) \ Chris@16: , typename boost::parameter::aux::match< \ Chris@16: parameters, BOOST_PP_ENUM_PARAMS(n, ParameterArgumentType) \ Chris@16: >::type = parameters() Chris@16: # else Chris@16: # define BOOST_PARAMETER_FUNCTION_FWD_MATCH_Z(z, name, parameters, n) Chris@16: # endif Chris@16: /**/ Chris@16: Chris@16: # define BOOST_PARAMETER_FUNCTION_PARAMETERS_NAME(base) \ Chris@16: BOOST_PP_CAT( \ Chris@16: boost_param_parameters_ \ Chris@16: , BOOST_PP_CAT(__LINE__, BOOST_PARAMETER_MEMBER_FUNCTION_NAME(base)) \ Chris@16: ) Chris@16: Chris@16: // Produce a name for a result type metafunction for the function Chris@16: // named base Chris@16: # define BOOST_PARAMETER_FUNCTION_RESULT_NAME(base) \ Chris@16: BOOST_PP_CAT( \ Chris@16: boost_param_result_ \ Chris@16: , BOOST_PP_CAT(__LINE__,BOOST_PARAMETER_MEMBER_FUNCTION_NAME(base)) \ Chris@16: ) Chris@16: Chris@16: // Can't do boost_param_impl_ ## basee because base might start with an underscore Chris@16: // daniel: what? how is that relevant? the reason for using CAT() is to make sure Chris@16: // base is expanded. i'm not sure we need to here, but it's more stable to do it. Chris@16: # define BOOST_PARAMETER_IMPL(base) \ Chris@16: BOOST_PP_CAT(boost_param_impl,BOOST_PARAMETER_MEMBER_FUNCTION_NAME(base)) Chris@16: Chris@16: # define BOOST_PARAMETER_FUNCTION_FWD_FUNCTION00(z, n, r, data, elem) \ Chris@16: BOOST_PP_IF( \ Chris@16: n \ Chris@16: , BOOST_PARAMETER_FUNCTION_FWD_FUNCTION_TEMPLATE_Z, BOOST_PP_TUPLE_EAT(2) \ Chris@16: )(z,n) \ Chris@16: BOOST_PARAMETER_MEMBER_FUNCTION_STATIC(BOOST_PP_TUPLE_ELEM(7,3,data)) \ Chris@16: inline \ Chris@16: BOOST_PP_EXPR_IF(n, typename) \ Chris@16: BOOST_PARAMETER_FUNCTION_RESULT_NAME(BOOST_PP_TUPLE_ELEM(7,3,data))< \ Chris@16: BOOST_PP_EXPR_IF(n, typename) \ Chris@16: boost::parameter::aux::argument_pack< \ Chris@16: BOOST_PARAMETER_FUNCTION_PARAMETERS_NAME(BOOST_PP_TUPLE_ELEM(7,3,data)) \ Chris@16: BOOST_PP_COMMA_IF(n) \ Chris@16: BOOST_PP_IF( \ Chris@16: n, BOOST_PP_SEQ_ENUM, BOOST_PP_TUPLE_EAT(1) \ Chris@16: )(elem) \ Chris@16: >::type \ Chris@16: >::type \ Chris@16: BOOST_PARAMETER_MEMBER_FUNCTION_NAME(BOOST_PP_TUPLE_ELEM(7,3,data))( \ Chris@16: BOOST_PP_IF( \ Chris@16: n \ Chris@16: , BOOST_PP_SEQ_FOR_EACH_I_R \ Chris@16: , BOOST_PP_TUPLE_EAT(4) \ Chris@16: )( \ Chris@16: r \ Chris@16: , BOOST_PARAMETER_FUNCTION_ARGUMENT \ Chris@16: , ~ \ Chris@16: , elem \ Chris@16: ) \ Chris@16: BOOST_PP_IF(n, BOOST_PARAMETER_FUNCTION_FWD_MATCH_Z, BOOST_PP_TUPLE_EAT(4))( \ Chris@16: z \ Chris@16: , BOOST_PP_TUPLE_ELEM(7,3,data) \ Chris@16: , BOOST_PARAMETER_FUNCTION_PARAMETERS_NAME(BOOST_PP_TUPLE_ELEM(7,3,data)) \ Chris@16: , n \ Chris@16: ) \ Chris@16: ) BOOST_PP_EXPR_IF(BOOST_PP_TUPLE_ELEM(7,4,data), const) \ Chris@16: { \ Chris@16: return BOOST_PARAMETER_IMPL(BOOST_PP_TUPLE_ELEM(7,3,data))( \ Chris@16: BOOST_PARAMETER_FUNCTION_PARAMETERS_NAME(BOOST_PP_TUPLE_ELEM(7,3,data))()( \ Chris@16: BOOST_PP_ENUM_PARAMS_Z(z, n, a) \ Chris@16: ) \ Chris@16: ); \ Chris@16: } Chris@16: /**/ Chris@16: Chris@16: # define BOOST_PARAMETER_FUNCTION_FWD_FUNCTION0(r, data, elem) \ Chris@16: BOOST_PARAMETER_FUNCTION_FWD_FUNCTION00( \ Chris@16: BOOST_PP_TUPLE_ELEM(7,0,data) \ Chris@16: , BOOST_PP_TUPLE_ELEM(7,1,data) \ Chris@16: , r \ Chris@16: , data \ Chris@16: , elem \ Chris@16: ) Chris@16: /**/ Chris@16: Chris@16: # define BOOST_PARAMETER_FUNCTION_FWD_FUNCTION_ARITY_0(z, n, data) \ Chris@16: BOOST_PARAMETER_FUNCTION_FWD_FUNCTION00( \ Chris@16: z, n, BOOST_PP_DEDUCE_R() \ Chris@16: , (z, n, BOOST_PP_TUPLE_REM(5) data) \ Chris@16: , ~ \ Chris@16: ) Chris@16: /**/ Chris@16: Chris@16: # define BOOST_PARAMETER_FUNCTION_FWD_FUNCTION_ARITY_N(z, n, data) \ Chris@16: BOOST_PP_SEQ_FOR_EACH( \ Chris@16: BOOST_PARAMETER_FUNCTION_FWD_FUNCTION0 \ Chris@16: , (z, n, BOOST_PP_TUPLE_REM(5) data) \ Chris@16: , BOOST_PP_SEQ_FOR_EACH_PRODUCT( \ Chris@16: BOOST_PARAMETER_FUNCTION_FWD_PRODUCT \ Chris@16: , BOOST_PP_SEQ_FIRST_N( \ Chris@16: n, BOOST_PP_TUPLE_ELEM(5,3,data) \ Chris@16: ) \ Chris@16: ) \ Chris@16: ) Chris@16: /**/ Chris@16: Chris@16: # define BOOST_PARAMETER_FUNCTION_FWD_FUNCTION(z, n, data) \ Chris@16: BOOST_PP_IF( \ Chris@16: n \ Chris@16: , BOOST_PARAMETER_FUNCTION_FWD_FUNCTION_ARITY_N \ Chris@16: , BOOST_PARAMETER_FUNCTION_FWD_FUNCTION_ARITY_0 \ Chris@16: )(z,n,data) \ Chris@16: /**/ Chris@16: Chris@16: # define BOOST_PARAMETER_FUNCTION_FWD_FUNCTIONS0( \ Chris@16: result,name,args,const_,combinations,range \ Chris@16: ) \ Chris@16: BOOST_PP_REPEAT_FROM_TO( \ Chris@16: BOOST_PP_TUPLE_ELEM(2,0,range), BOOST_PP_TUPLE_ELEM(2,1,range) \ Chris@16: , BOOST_PARAMETER_FUNCTION_FWD_FUNCTION \ Chris@16: , (result,name,const_,combinations,BOOST_PP_TUPLE_ELEM(2,1,range)) \ Chris@16: ) Chris@16: /**/ Chris@16: Chris@16: # define BOOST_PARAMETER_FUNCTION_FWD_FUNCTIONS(result,name,args, const_, combinations) \ Chris@16: BOOST_PARAMETER_FUNCTION_FWD_FUNCTIONS0( \ Chris@16: result, name, args, const_, combinations, BOOST_PARAMETER_ARITY_RANGE(args) \ Chris@16: ) Chris@16: /**/ Chris@16: Chris@16: // Builds boost::parameter::parameters<> specialization Chris@16: # define BOOST_PARAMETER_FUNCTION_PARAMETERS_QUALIFIER_optional(tag) \ Chris@16: optional Chris@16: Chris@16: # define BOOST_PARAMETER_FUNCTION_PARAMETERS_QUALIFIER_deduced_required(tag) \ Chris@16: required Chris@16: Chris@16: # if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) && !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) Chris@16: Chris@16: # if BOOST_WORKAROUND(BOOST_MSVC, == 1300) Chris@16: # define BOOST_PARAMETER_PREDICATE_TYPE(p) void*(*) (void* p) Chris@16: # else Chris@16: # define BOOST_PARAMETER_PREDICATE_TYPE(p) void p Chris@16: # endif Chris@16: Chris@16: # define BOOST_PARAMETER_FUNCTION_PARAMETERS_M(r,tag_namespace,i,elem) \ Chris@16: BOOST_PP_COMMA_IF(i) \ Chris@16: boost::parameter::BOOST_PP_CAT( \ Chris@16: BOOST_PARAMETER_FUNCTION_PARAMETERS_QUALIFIER_ \ Chris@16: , BOOST_PARAMETER_FN_ARG_QUALIFIER(elem) \ Chris@16: )( \ Chris@16: tag_namespace::BOOST_PARAMETER_FUNCTION_KEYWORD( \ Chris@16: BOOST_PARAMETER_FN_ARG_KEYWORD(elem) \ Chris@16: ) \ Chris@16: ) \ Chris@16: , typename boost::parameter::aux::unwrap_predicate< \ Chris@16: BOOST_PARAMETER_PREDICATE_TYPE(BOOST_PARAMETER_FN_ARG_PRED(elem)) \ Chris@16: >::type \ Chris@16: > Chris@16: # elif BOOST_WORKAROUND(BOOST_MSVC, < 1300) Chris@16: # define BOOST_PARAMETER_FUNCTION_PARAMETERS_M(r,tag_namespace,i,elem) \ Chris@16: BOOST_PP_COMMA_IF(i) \ Chris@16: boost::parameter::BOOST_PP_CAT( \ Chris@16: BOOST_PARAMETER_FUNCTION_PARAMETERS_QUALIFIER_ \ Chris@16: , BOOST_PARAMETER_FN_ARG_QUALIFIER(elem) \ Chris@16: )( \ Chris@16: tag_namespace::BOOST_PARAMETER_FUNCTION_KEYWORD( \ Chris@16: BOOST_PARAMETER_FN_ARG_KEYWORD(elem) \ Chris@16: ) \ Chris@16: ) \ Chris@16: , boost::parameter::aux::funptr_predicate< \ Chris@16: void* BOOST_PARAMETER_FN_ARG_PRED(elem) \ Chris@16: > \ Chris@16: > Chris@16: # elif BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) Chris@16: # define BOOST_PARAMETER_FUNCTION_PARAMETERS_M(r,tag_namespace,i,elem) \ Chris@16: BOOST_PP_COMMA_IF(i) \ Chris@16: boost::parameter::BOOST_PP_CAT( \ Chris@16: BOOST_PARAMETER_FUNCTION_PARAMETERS_QUALIFIER_ \ Chris@16: , BOOST_PARAMETER_FN_ARG_QUALIFIER(elem) \ Chris@16: )( \ Chris@16: tag_namespace::BOOST_PARAMETER_FUNCTION_KEYWORD( \ Chris@16: BOOST_PARAMETER_FN_ARG_KEYWORD(elem) \ Chris@16: ) \ Chris@16: ) \ Chris@16: , boost::mpl::always \ Chris@16: > Chris@16: # endif Chris@16: Chris@16: # define BOOST_PARAMETER_FUNCTION_PARAMETERS(tag_namespace, base, args) \ Chris@16: template \ Chris@16: struct BOOST_PP_CAT( \ Chris@16: BOOST_PP_CAT(boost_param_params_, __LINE__) \ Chris@16: , BOOST_PARAMETER_MEMBER_FUNCTION_NAME(base) \ Chris@16: ) : boost::parameter::parameters< \ Chris@16: BOOST_PP_SEQ_FOR_EACH_I( \ Chris@16: BOOST_PARAMETER_FUNCTION_PARAMETERS_M, tag_namespace, args \ Chris@16: ) \ Chris@16: > \ Chris@16: {}; \ Chris@16: \ Chris@16: typedef BOOST_PP_CAT( \ Chris@16: BOOST_PP_CAT(boost_param_params_, __LINE__) \ Chris@16: , BOOST_PARAMETER_MEMBER_FUNCTION_NAME(base) \ Chris@16: ) Chris@16: Chris@16: // Defines result type metafunction Chris@16: # define BOOST_PARAMETER_FUNCTION_RESULT_ARG(z, _, i, x) \ Chris@16: BOOST_PP_COMMA_IF(i) class BOOST_PP_TUPLE_ELEM(3,1,x) Chris@16: /**/ Chris@16: Chris@16: # define BOOST_PARAMETER_FUNCTION_RESULT_(result, name, args) \ Chris@16: template \ Chris@16: struct BOOST_PARAMETER_FUNCTION_RESULT_NAME(name) \ Chris@16: { \ Chris@16: typedef typename BOOST_PARAMETER_PARENTHESIZED_TYPE(result) type; \ Chris@16: }; Chris@16: Chris@16: # if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) Chris@16: Chris@16: # define BOOST_PARAMETER_FUNCTION_RESULT(result, name, args) \ Chris@16: BOOST_PARAMETER_FUNCTION_RESULT_(result, name, args) \ Chris@16: template <> \ Chris@16: struct BOOST_PARAMETER_FUNCTION_RESULT_NAME(name) \ Chris@16: { typedef int type; }; Chris@16: Chris@16: # else Chris@16: Chris@16: # define BOOST_PARAMETER_FUNCTION_RESULT(result, name, args) \ Chris@16: BOOST_PARAMETER_FUNCTION_RESULT_(result, name, args) Chris@16: Chris@16: # endif Chris@16: Chris@16: // Defines implementation function Chris@16: # define BOOST_PARAMETER_FUNCTION_IMPL_HEAD(name) \ Chris@16: template \ Chris@16: typename BOOST_PARAMETER_FUNCTION_RESULT_NAME(name)< \ Chris@16: Args \ Chris@16: >::type BOOST_PARAMETER_IMPL(name)(Args const& args) Chris@16: Chris@16: # define BOOST_PARAMETER_FUNCTION_IMPL_FWD(name) \ Chris@16: BOOST_PARAMETER_FUNCTION_IMPL_HEAD(name); Chris@16: /**/ Chris@16: Chris@16: # define BOOST_PARAMETER_FUNCTION_SPLIT_ARG_required(state, arg) \ Chris@16: ( \ Chris@16: BOOST_PP_INC(BOOST_PP_TUPLE_ELEM(4, 0, state)) \ Chris@16: , BOOST_PP_SEQ_PUSH_BACK(BOOST_PP_TUPLE_ELEM(4, 1, state), arg) \ Chris@16: , BOOST_PP_TUPLE_ELEM(4, 2, state) \ Chris@16: , BOOST_PP_TUPLE_ELEM(4, 3, state) \ Chris@16: ) Chris@16: Chris@16: # define BOOST_PARAMETER_FUNCTION_SPLIT_ARG_deduced_required(state, arg) \ Chris@16: BOOST_PARAMETER_FUNCTION_SPLIT_ARG_required(state, arg) Chris@16: Chris@16: # define BOOST_PARAMETER_FUNCTION_SPLIT_ARG_optional(state, arg) \ Chris@16: ( \ Chris@16: BOOST_PP_TUPLE_ELEM(4, 0, state) \ Chris@16: , BOOST_PP_TUPLE_ELEM(4, 1, state) \ Chris@16: , BOOST_PP_INC(BOOST_PP_TUPLE_ELEM(4, 2, state)) \ Chris@16: , BOOST_PP_SEQ_PUSH_BACK(BOOST_PP_TUPLE_ELEM(4, 3, state), arg) \ Chris@16: ) Chris@16: Chris@16: # define BOOST_PARAMETER_FUNCTION_SPLIT_ARG_deduced_optional(state, arg) \ Chris@16: BOOST_PARAMETER_FUNCTION_SPLIT_ARG_optional(state, arg) Chris@16: Chris@16: # define BOOST_PARAMETER_FUNCTION_SPLIT_ARG(s, state, arg) \ Chris@16: BOOST_PP_CAT( \ Chris@16: BOOST_PARAMETER_FUNCTION_SPLIT_ARG_ \ Chris@16: , BOOST_PARAMETER_FN_ARG_QUALIFIER(arg) \ Chris@16: )(state, arg) Chris@16: Chris@16: // Returns (required_count, required, optional_count, optionals) tuple Chris@16: # define BOOST_PARAMETER_FUNCTION_SPLIT_ARGS(args) \ Chris@16: BOOST_PP_SEQ_FOLD_LEFT( \ Chris@16: BOOST_PARAMETER_FUNCTION_SPLIT_ARG \ Chris@16: , (0,BOOST_PP_SEQ_NIL, 0,BOOST_PP_SEQ_NIL) \ Chris@16: , args \ Chris@16: ) Chris@16: Chris@16: # define BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION_ARG_NAME(keyword) \ Chris@16: BOOST_PP_CAT(BOOST_PP_CAT(keyword,_),type) Chris@16: Chris@16: // Helpers used as parameters to BOOST_PARAMETER_FUNCTION_DEFAULT_ARGUMENTS. Chris@16: # define BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION_TEMPLATE_ARG(r, _, arg) \ Chris@16: , class BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION_ARG_NAME( \ Chris@16: BOOST_PARAMETER_FN_ARG_KEYWORD(arg) \ Chris@16: ) Chris@16: Chris@16: # define BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION_ARG(r, _, arg) \ Chris@16: , BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION_ARG_NAME( \ Chris@16: BOOST_PARAMETER_FN_ARG_KEYWORD(arg) \ Chris@16: )& BOOST_PARAMETER_FN_ARG_KEYWORD(arg) Chris@16: Chris@16: # define BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION_PARAMETER(r, _, arg) \ Chris@16: , BOOST_PARAMETER_FN_ARG_KEYWORD(arg) Chris@16: Chris@16: // Produces a name for the dispatch functions. Chris@16: # define BOOST_PARAMETER_FUNCTION_DEFAULT_NAME(name) \ Chris@16: BOOST_PP_CAT( \ Chris@16: boost_param_default_ \ Chris@16: , BOOST_PP_CAT(__LINE__, BOOST_PARAMETER_MEMBER_FUNCTION_NAME(name)) \ Chris@16: ) Chris@16: Chris@16: // Helper macro used below to produce lists based on the keyword argument Chris@16: // names. macro is applied to every element. n is the number of Chris@16: // optional arguments that should be included. Chris@16: # define BOOST_PARAMETER_FUNCTION_DEFAULT_ARGUMENTS(macro, n, split_args) \ Chris@16: BOOST_PP_SEQ_FOR_EACH( \ Chris@16: macro \ Chris@16: , ~ \ Chris@16: , BOOST_PP_TUPLE_ELEM(4,1,split_args) \ Chris@16: ) \ Chris@16: BOOST_PP_SEQ_FOR_EACH( \ Chris@16: macro \ Chris@16: , ~ \ Chris@16: , BOOST_PP_SEQ_FIRST_N( \ Chris@16: BOOST_PP_SUB(BOOST_PP_TUPLE_ELEM(4,2,split_args), n) \ Chris@16: , BOOST_PP_TUPLE_ELEM(4,3,split_args) \ Chris@16: ) \ Chris@16: ) Chris@16: Chris@16: // Generates a keyword | default expression. Chris@16: # define BOOST_PARAMETER_FUNCTION_DEFAULT_EVAL_DEFAULT(arg, tag_namespace) \ Chris@16: boost::parameter::keyword< \ Chris@16: tag_namespace::BOOST_PARAMETER_FN_ARG_KEYWORD(arg) \ Chris@16: >::instance | boost::parameter::aux::use_default_tag() Chris@16: Chris@16: # define BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION_GET_ARG(arg, tag_ns) \ Chris@16: BOOST_PARAMETER_FUNCTION_CAST( \ Chris@16: args[ \ Chris@16: BOOST_PARAMETER_FUNCTION_DEFAULT_EVAL_DEFAULT( \ Chris@16: arg, tag_ns \ Chris@16: ) \ Chris@16: ] \ Chris@16: , BOOST_PARAMETER_FN_ARG_PRED(arg) \ Chris@16: , Args \ Chris@16: ) Chris@16: Chris@16: # define BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION_BODY(name, n, split_args, tag_namespace) \ Chris@16: { \ Chris@16: return BOOST_PARAMETER_FUNCTION_DEFAULT_NAME(name)( \ Chris@16: (ResultType(*)())0 \ Chris@16: , args \ Chris@16: , 0L \ Chris@16: BOOST_PARAMETER_FUNCTION_DEFAULT_ARGUMENTS( \ Chris@16: BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION_PARAMETER \ Chris@16: , n \ Chris@16: , split_args \ Chris@16: ) \ Chris@16: , BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION_GET_ARG( \ Chris@16: BOOST_PP_SEQ_ELEM( \ Chris@16: BOOST_PP_SUB(BOOST_PP_TUPLE_ELEM(4,2,split_args), n) \ Chris@16: , BOOST_PP_TUPLE_ELEM(4,3,split_args) \ Chris@16: ) \ Chris@16: , tag_namespace \ Chris@16: ) \ Chris@16: ); \ Chris@16: } Chris@16: Chris@16: # define BOOST_PARAMETER_FUNCTION_DEFAULT_EVAL_ACTUAL_DEFAULT(arg) \ Chris@16: BOOST_PARAMETER_FUNCTION_CAST( \ Chris@16: boost::parameter::aux::as_lvalue(BOOST_PARAMETER_FN_ARG_DEFAULT(arg), 0L) \ Chris@16: , BOOST_PARAMETER_FN_ARG_PRED(arg) \ Chris@16: , Args \ Chris@16: ) Chris@16: Chris@16: # define BOOST_PARAMETER_FUNCTION_DEFAULT_EVAL_DEFAULT_BODY(name, n, split_args, tag_ns, const_) \ Chris@16: template < \ Chris@16: class ResultType \ Chris@16: , class Args \ Chris@16: BOOST_PARAMETER_FUNCTION_DEFAULT_ARGUMENTS( \ Chris@16: BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION_TEMPLATE_ARG \ Chris@16: , BOOST_PP_INC(n) \ Chris@16: , split_args \ Chris@16: ) \ Chris@16: > \ Chris@16: BOOST_PARAMETER_MEMBER_FUNCTION_STATIC(name) \ Chris@16: ResultType BOOST_PARAMETER_FUNCTION_DEFAULT_NAME(name)( \ Chris@16: ResultType(*)() \ Chris@16: , Args const& args \ Chris@16: , long \ Chris@16: BOOST_PARAMETER_FUNCTION_DEFAULT_ARGUMENTS( \ Chris@16: BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION_ARG \ Chris@16: , BOOST_PP_INC(n) \ Chris@16: , split_args \ Chris@16: ) \ Chris@16: , boost::parameter::aux::use_default_tag \ Chris@16: ) BOOST_PP_EXPR_IF(const_, const) \ Chris@16: { \ Chris@16: return BOOST_PARAMETER_FUNCTION_DEFAULT_NAME(name)( \ Chris@16: (ResultType(*)())0 \ Chris@16: , args \ Chris@16: , 0L \ Chris@16: BOOST_PARAMETER_FUNCTION_DEFAULT_ARGUMENTS( \ Chris@16: BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION_PARAMETER \ Chris@16: , BOOST_PP_INC(n) \ Chris@16: , split_args \ Chris@16: ) \ Chris@16: , BOOST_PARAMETER_FUNCTION_DEFAULT_EVAL_ACTUAL_DEFAULT( \ Chris@16: BOOST_PP_SEQ_ELEM( \ Chris@16: BOOST_PP_SUB(BOOST_PP_TUPLE_ELEM(4,2,split_args), BOOST_PP_INC(n)) \ Chris@16: , BOOST_PP_TUPLE_ELEM(4,3,split_args) \ Chris@16: ) \ Chris@16: ) \ Chris@16: ); \ Chris@16: } Chris@16: Chris@16: // Produces a forwarding layer in the default evaluation machine. Chris@16: // Chris@16: // data is a tuple: Chris@16: // Chris@16: // (name, split_args) Chris@16: // Chris@16: // Where name is the base name of the function, and split_args is a tuple: Chris@16: // Chris@16: // (required_count, required_args, optional_count, required_args) Chris@16: // Chris@16: Chris@16: Chris@16: // defines the actual function body for BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION below. Chris@16: # define BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION0(z, n, data) \ Chris@16: template < \ Chris@16: class ResultType \ Chris@16: , class Args \ Chris@16: BOOST_PARAMETER_FUNCTION_DEFAULT_ARGUMENTS( \ Chris@16: BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION_TEMPLATE_ARG \ Chris@16: , n \ Chris@16: , BOOST_PP_TUPLE_ELEM(5,1,data) \ Chris@16: ) \ Chris@16: > \ Chris@16: BOOST_PARAMETER_MEMBER_FUNCTION_STATIC(BOOST_PP_TUPLE_ELEM(5,0,data)) \ Chris@16: ResultType BOOST_PARAMETER_FUNCTION_DEFAULT_NAME(BOOST_PP_TUPLE_ELEM(5,0,data))( \ Chris@16: ResultType(*)() \ Chris@16: , Args const& args \ Chris@16: , int \ Chris@16: BOOST_PARAMETER_FUNCTION_DEFAULT_ARGUMENTS( \ Chris@16: BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION_ARG \ Chris@16: , n \ Chris@16: , BOOST_PP_TUPLE_ELEM(5,1,data) \ Chris@16: ) \ Chris@16: ) BOOST_PP_EXPR_IF(BOOST_PP_TUPLE_ELEM(5,2,data), const) \ Chris@16: BOOST_PP_IF( \ Chris@16: n \ Chris@16: , BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION_BODY \ Chris@16: , ; BOOST_PP_TUPLE_EAT(4) \ Chris@16: )( \ Chris@16: BOOST_PP_TUPLE_ELEM(5,0,data) \ Chris@16: , n \ Chris@16: , BOOST_PP_TUPLE_ELEM(5,1,data) \ Chris@16: , BOOST_PP_TUPLE_ELEM(5,3,data) \ Chris@16: ) Chris@16: Chris@16: # define BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION(z, n, data) \ Chris@16: BOOST_PP_IF( \ Chris@16: BOOST_PP_AND( \ Chris@16: BOOST_PP_NOT(n) \ Chris@16: , BOOST_PP_TUPLE_ELEM(5,4,data) \ Chris@16: ) \ Chris@16: , BOOST_PP_TUPLE_EAT(3) \ Chris@16: , BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION0 \ Chris@16: )(z, n, data) \ Chris@16: BOOST_PP_IF( \ Chris@16: BOOST_PP_EQUAL(n, BOOST_PP_TUPLE_ELEM(4,2,BOOST_PP_TUPLE_ELEM(5,1,data))) \ Chris@16: , BOOST_PP_TUPLE_EAT(5) \ Chris@16: , BOOST_PARAMETER_FUNCTION_DEFAULT_EVAL_DEFAULT_BODY \ Chris@16: )( \ Chris@16: BOOST_PP_TUPLE_ELEM(5,0,data) \ Chris@16: , n \ Chris@16: , BOOST_PP_TUPLE_ELEM(5,1,data) \ Chris@16: , BOOST_PP_TUPLE_ELEM(5,3,data) \ Chris@16: , BOOST_PP_TUPLE_ELEM(5,2,data) \ Chris@16: ) Chris@16: Chris@16: # define BOOST_PARAMETER_FUNCTION_DEFAULT_GET_ARG(r, tag_ns, arg) \ Chris@16: , BOOST_PARAMETER_FUNCTION_CAST( \ Chris@16: args[ \ Chris@16: boost::parameter::keyword::instance \ Chris@16: ] \ Chris@16: , BOOST_PARAMETER_FN_ARG_PRED(arg) \ Chris@16: , Args \ Chris@16: ) Chris@16: Chris@16: // Generates the function template that recives a ArgumentPack, and then Chris@16: // goes on to call the layers of overloads generated by Chris@16: // BOOST_PARAMETER_FUNCTION_DEFAULT_LAYER. Chris@16: # define BOOST_PARAMETER_FUNCTION_INITIAL_DISPATCH_FUNCTION(name, split_args, const_, tag_ns) \ Chris@16: template \ Chris@16: typename BOOST_PARAMETER_FUNCTION_RESULT_NAME(name)::type \ Chris@16: BOOST_PARAMETER_MEMBER_FUNCTION_STATIC(name) \ Chris@16: BOOST_PARAMETER_IMPL(name)(Args const& args) BOOST_PP_EXPR_IF(const_, const) \ Chris@16: { \ Chris@16: return BOOST_PARAMETER_FUNCTION_DEFAULT_NAME(name)( \ Chris@16: (typename BOOST_PARAMETER_FUNCTION_RESULT_NAME(name)::type(*)())0 \ Chris@16: , args \ Chris@16: , 0L \ Chris@16: \ Chris@16: BOOST_PP_SEQ_FOR_EACH( \ Chris@16: BOOST_PARAMETER_FUNCTION_DEFAULT_GET_ARG \ Chris@16: , tag_ns \ Chris@16: , BOOST_PP_TUPLE_ELEM(4,1,split_args) \ Chris@16: ) \ Chris@16: \ Chris@16: ); \ Chris@16: } Chris@16: Chris@16: // Helper for BOOST_PARAMETER_FUNCTION_DEFAULT_LAYER below. Chris@16: # define BOOST_PARAMETER_FUNCTION_DEFAULT_LAYER_AUX( \ Chris@16: name, split_args, skip_fwd_decl, const_, tag_namespace \ Chris@16: ) \ Chris@16: BOOST_PP_REPEAT_FROM_TO( \ Chris@16: 0 \ Chris@16: , BOOST_PP_INC(BOOST_PP_TUPLE_ELEM(4, 2, split_args)) \ Chris@16: , BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION \ Chris@16: , (name, split_args, const_, tag_namespace, skip_fwd_decl) \ Chris@16: ) \ Chris@16: \ Chris@16: BOOST_PARAMETER_FUNCTION_INITIAL_DISPATCH_FUNCTION(name, split_args, const_, tag_namespace) \ Chris@16: \ Chris@16: template < \ Chris@16: class ResultType \ Chris@16: , class Args \ Chris@16: BOOST_PARAMETER_FUNCTION_DEFAULT_ARGUMENTS( \ Chris@16: BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION_TEMPLATE_ARG \ Chris@16: , 0 \ Chris@16: , split_args \ Chris@16: ) \ Chris@16: > \ Chris@16: BOOST_PARAMETER_MEMBER_FUNCTION_STATIC(name) \ Chris@16: ResultType BOOST_PARAMETER_FUNCTION_DEFAULT_NAME(name)( \ Chris@16: ResultType(*)() \ Chris@16: , Args const& args \ Chris@16: , int \ Chris@16: BOOST_PARAMETER_FUNCTION_DEFAULT_ARGUMENTS( \ Chris@16: BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION_ARG \ Chris@16: , 0 \ Chris@16: , split_args \ Chris@16: ) \ Chris@16: ) BOOST_PP_EXPR_IF(const_, const) Chris@16: Chris@16: // Generates a bunch of forwarding functions that each extract Chris@16: // one more argument. Chris@16: # define BOOST_PARAMETER_FUNCTION_DEFAULT_LAYER(name, args, skip_fwd_decl, const_, tag_ns) \ Chris@16: BOOST_PARAMETER_FUNCTION_DEFAULT_LAYER_AUX( \ Chris@16: name, BOOST_PARAMETER_FUNCTION_SPLIT_ARGS(args), skip_fwd_decl, const_, tag_ns \ Chris@16: ) Chris@16: /**/ Chris@16: Chris@16: // Defines the result metafunction and the parameters specialization. Chris@16: # define BOOST_PARAMETER_FUNCTION_HEAD(result, name, tag_namespace, args) \ Chris@16: BOOST_PARAMETER_FUNCTION_RESULT(result, name, args) \ Chris@16: \ Chris@16: BOOST_PARAMETER_FUNCTION_PARAMETERS(tag_namespace, name, args) \ Chris@16: BOOST_PARAMETER_FUNCTION_PARAMETERS_NAME(name); \ Chris@16: Chris@16: // Helper for BOOST_PARAMETER_FUNCTION below. Chris@16: # define BOOST_PARAMETER_FUNCTION_AUX(result, name, tag_namespace, args) \ Chris@16: BOOST_PARAMETER_FUNCTION_HEAD(result, name, tag_namespace, args) \ Chris@16: BOOST_PARAMETER_FUNCTION_IMPL_HEAD(name); \ Chris@16: \ Chris@16: BOOST_PARAMETER_FUNCTION_FWD_FUNCTIONS( \ Chris@16: result, name, args, 0 \ Chris@16: , BOOST_PARAMETER_FUNCTION_FWD_COMBINATIONS(args) \ Chris@16: ) \ Chris@16: \ Chris@16: BOOST_PARAMETER_FUNCTION_DEFAULT_LAYER(name, args, 0, 0, tag_namespace) Chris@16: Chris@16: // Defines a Boost.Parameter enabled function with the new syntax. Chris@16: # define BOOST_PARAMETER_FUNCTION(result, name, tag_namespace, args) \ Chris@16: BOOST_PARAMETER_FUNCTION_AUX( \ Chris@16: result, name, tag_namespace \ Chris@16: , BOOST_PARAMETER_FLATTEN(3, 2, 3, args) \ Chris@16: ) \ Chris@16: /**/ Chris@16: Chris@16: // Defines a Boost.Parameter enabled function. Chris@16: # define BOOST_PARAMETER_BASIC_FUNCTION_AUX(result, name, tag_namespace, args) \ Chris@16: BOOST_PARAMETER_FUNCTION_HEAD(result, name, tag_namespace, args) \ Chris@16: \ Chris@16: BOOST_PARAMETER_FUNCTION_IMPL_FWD(name) \ Chris@16: \ Chris@16: BOOST_PARAMETER_FUNCTION_FWD_FUNCTIONS( \ Chris@16: result, name, args, 0 \ Chris@16: , BOOST_PARAMETER_FUNCTION_FWD_COMBINATIONS(args) \ Chris@16: ) \ Chris@16: \ Chris@16: BOOST_PARAMETER_FUNCTION_IMPL_HEAD(name) Chris@16: Chris@16: # define BOOST_PARAMETER_BASIC_FUNCTION(result, name, tag_namespace, args) \ Chris@16: BOOST_PARAMETER_BASIC_FUNCTION_AUX( \ Chris@16: result, name, tag_namespace \ Chris@16: , BOOST_PARAMETER_FLATTEN(2, 2, 3, args) \ Chris@16: ) \ Chris@16: /**/ Chris@16: Chris@16: // Defines a Boost.Parameter enabled member function. Chris@16: # define BOOST_PARAMETER_BASIC_MEMBER_FUNCTION_AUX(result, name, tag_namespace, args, const_) \ Chris@16: BOOST_PARAMETER_FUNCTION_HEAD(result, name, tag_namespace, args) \ Chris@16: \ Chris@16: BOOST_PARAMETER_FUNCTION_FWD_FUNCTIONS( \ Chris@16: result, name, args, const_ \ Chris@16: , BOOST_PARAMETER_FUNCTION_FWD_COMBINATIONS(args) \ Chris@16: ) \ Chris@16: \ Chris@16: BOOST_PARAMETER_FUNCTION_IMPL_HEAD(name) BOOST_PP_EXPR_IF(const_, const) \ Chris@16: /**/ Chris@16: Chris@16: # define BOOST_PARAMETER_BASIC_MEMBER_FUNCTION(result, name, tag_namespace, args) \ Chris@16: BOOST_PARAMETER_BASIC_MEMBER_FUNCTION_AUX( \ Chris@16: result, name, tag_namespace \ Chris@16: , BOOST_PARAMETER_FLATTEN(2, 2, 3, args) \ Chris@16: , 0 \ Chris@16: ) Chris@16: /**/ Chris@16: Chris@16: # define BOOST_PARAMETER_BASIC_CONST_MEMBER_FUNCTION(result, name, tag_namespace, args) \ Chris@16: BOOST_PARAMETER_BASIC_MEMBER_FUNCTION_AUX( \ Chris@16: result, name, tag_namespace \ Chris@16: , BOOST_PARAMETER_FLATTEN(2, 2, 3, args) \ Chris@16: , 1 \ Chris@16: ) Chris@16: /**/ Chris@16: Chris@16: Chris@16: Chris@16: # define BOOST_PARAMETER_MEMBER_FUNCTION_AUX(result, name, tag_namespace, const_, args) \ Chris@16: BOOST_PARAMETER_FUNCTION_HEAD(result, name, tag_namespace, args) \ Chris@16: \ Chris@16: BOOST_PARAMETER_FUNCTION_FWD_FUNCTIONS( \ Chris@16: result, name, args, const_ \ Chris@16: , BOOST_PARAMETER_FUNCTION_FWD_COMBINATIONS(args) \ Chris@16: ) \ Chris@16: \ Chris@16: BOOST_PARAMETER_FUNCTION_DEFAULT_LAYER(name, args, 1, const_, tag_namespace) Chris@16: Chris@16: // Defines a Boost.Parameter enabled function with the new syntax. Chris@16: # define BOOST_PARAMETER_MEMBER_FUNCTION(result, name, tag_namespace, args) \ Chris@16: BOOST_PARAMETER_MEMBER_FUNCTION_AUX( \ Chris@16: result, name, tag_namespace, 0 \ Chris@16: , BOOST_PARAMETER_FLATTEN(3, 2, 3, args) \ Chris@16: ) \ Chris@16: /**/ Chris@16: Chris@16: # define BOOST_PARAMETER_CONST_MEMBER_FUNCTION(result, name, tag_namespace, args) \ Chris@16: BOOST_PARAMETER_MEMBER_FUNCTION_AUX( \ Chris@16: result, name, tag_namespace, 1 \ Chris@16: , BOOST_PARAMETER_FLATTEN(3, 2, 3, args) \ Chris@16: ) \ Chris@16: /**/ Chris@16: Chris@16: // Defines a Boost.Parameter enabled constructor. Chris@16: Chris@16: # define BOOST_PARAMETER_FUNCTION_ARGUMENT(r, _, i, elem) \ Chris@16: BOOST_PP_COMMA_IF(i) elem& BOOST_PP_CAT(a, i) Chris@16: /**/ Chris@16: Chris@16: # if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) Chris@16: Chris@16: // Older MSVC can't do what's necessary to handle commas in base names; just Chris@16: // use a typedef instead if you have a base name that contains commas. Chris@16: # define BOOST_PARAMETER_PARENTHESIZED_BASE(x) BOOST_PP_SEQ_HEAD(x) Chris@16: Chris@16: # else Chris@16: Chris@16: # define BOOST_PARAMETER_PARENTHESIZED_BASE(x) BOOST_PARAMETER_PARENTHESIZED_TYPE(x) Chris@16: Chris@16: # endif Chris@16: Chris@16: # define BOOST_PARAMETER_FUNCTION_FWD_CONSTRUCTOR00(z, n, r, data, elem) \ Chris@16: BOOST_PP_IF( \ Chris@16: n \ Chris@16: , BOOST_PARAMETER_FUNCTION_FWD_FUNCTION_TEMPLATE_Z, BOOST_PP_TUPLE_EAT(2) \ Chris@16: )(z, n) \ Chris@16: BOOST_PP_EXPR_IF(BOOST_PP_EQUAL(n,1), explicit) \ Chris@16: BOOST_PP_TUPLE_ELEM(6,2,data)( \ Chris@16: BOOST_PP_IF( \ Chris@16: n \ Chris@16: , BOOST_PP_SEQ_FOR_EACH_I_R \ Chris@16: , BOOST_PP_TUPLE_EAT(4) \ Chris@16: )( \ Chris@16: r \ Chris@16: , BOOST_PARAMETER_FUNCTION_ARGUMENT \ Chris@16: , ~ \ Chris@16: , elem \ Chris@16: ) \ Chris@16: BOOST_PP_IF(n, BOOST_PARAMETER_FUNCTION_FWD_MATCH_Z, BOOST_PP_TUPLE_EAT(4))( \ Chris@16: z \ Chris@16: , BOOST_PP_TUPLE_ELEM(6,3,data) \ Chris@16: , BOOST_PP_CAT(constructor_parameters, __LINE__) \ Chris@16: , n \ Chris@16: ) \ Chris@16: ) \ Chris@16: : BOOST_PARAMETER_PARENTHESIZED_BASE(BOOST_PP_TUPLE_ELEM(6,3,data)) ( \ Chris@16: BOOST_PP_CAT(constructor_parameters, __LINE__)()( \ Chris@16: BOOST_PP_ENUM_PARAMS_Z(z, n, a) \ Chris@16: ) \ Chris@16: ) \ Chris@16: {} Chris@16: /**/ Chris@16: Chris@16: # define BOOST_PARAMETER_FUNCTION_FWD_CONSTRUCTOR0(r, data, elem) \ Chris@16: BOOST_PARAMETER_FUNCTION_FWD_CONSTRUCTOR00( \ Chris@16: BOOST_PP_TUPLE_ELEM(6,0,data) \ Chris@16: , BOOST_PP_TUPLE_ELEM(6,1,data) \ Chris@16: , r \ Chris@16: , data \ Chris@16: , elem \ Chris@16: ) Chris@16: /**/ Chris@16: Chris@16: # define BOOST_PARAMETER_FUNCTION_FWD_PRODUCT(r, product) \ Chris@16: (product) Chris@16: /**/ Chris@16: Chris@16: # define BOOST_PARAMETER_FUNCTION_FWD_CONSTRUCTOR_ARITY_0(z, n, data) \ Chris@16: BOOST_PARAMETER_FUNCTION_FWD_CONSTRUCTOR00( \ Chris@16: z, n, BOOST_PP_DEDUCE_R() \ Chris@16: , (z, n, BOOST_PP_TUPLE_REM(4) data) \ Chris@16: , ~ \ Chris@16: ) Chris@16: /**/ Chris@16: Chris@16: # define BOOST_PARAMETER_FUNCTION_FWD_CONSTRUCTOR_ARITY_N(z, n, data) \ Chris@16: BOOST_PP_SEQ_FOR_EACH( \ Chris@16: BOOST_PARAMETER_FUNCTION_FWD_CONSTRUCTOR0 \ Chris@16: , (z, n, BOOST_PP_TUPLE_REM(4) data) \ Chris@16: , BOOST_PP_SEQ_FOR_EACH_PRODUCT( \ Chris@16: BOOST_PARAMETER_FUNCTION_FWD_PRODUCT \ Chris@16: , BOOST_PP_SEQ_FIRST_N( \ Chris@16: n, BOOST_PP_TUPLE_ELEM(4,2,data) \ Chris@16: ) \ Chris@16: ) \ Chris@16: ) Chris@16: /**/ Chris@16: Chris@16: # define BOOST_PARAMETER_FUNCTION_FWD_CONSTRUCTOR(z, n, data) \ Chris@16: BOOST_PP_IF( \ Chris@16: n \ Chris@16: , BOOST_PARAMETER_FUNCTION_FWD_CONSTRUCTOR_ARITY_N \ Chris@16: , BOOST_PARAMETER_FUNCTION_FWD_CONSTRUCTOR_ARITY_0 \ Chris@16: )(z,n,data) \ Chris@16: /**/ Chris@16: Chris@16: # define BOOST_PARAMETER_FUNCTION_FWD_CONSTRUCTORS0(class_,base,args,combinations,range) \ Chris@16: BOOST_PP_REPEAT_FROM_TO( \ Chris@16: BOOST_PP_TUPLE_ELEM(2,0,range), BOOST_PP_TUPLE_ELEM(2,1,range) \ Chris@16: , BOOST_PARAMETER_FUNCTION_FWD_CONSTRUCTOR \ Chris@16: , (class_,base,combinations,BOOST_PP_TUPLE_ELEM(2,1,range)) \ Chris@16: ) Chris@16: /**/ Chris@16: Chris@16: # define BOOST_PARAMETER_FUNCTION_FWD_CONSTRUCTORS(class_,base,args,combinations) \ Chris@16: BOOST_PARAMETER_FUNCTION_FWD_CONSTRUCTORS0( \ Chris@16: class_, base, args, combinations, BOOST_PARAMETER_ARITY_RANGE(args) \ Chris@16: ) Chris@16: /**/ Chris@16: Chris@16: # define BOOST_PARAMETER_CONSTRUCTOR_AUX(class_, base, tag_namespace, args) \ Chris@16: BOOST_PARAMETER_FUNCTION_PARAMETERS(tag_namespace, ctor, args) \ Chris@16: BOOST_PP_CAT(constructor_parameters, __LINE__); \ Chris@16: \ Chris@16: BOOST_PARAMETER_FUNCTION_FWD_CONSTRUCTORS( \ Chris@16: class_, base, args \ Chris@16: , BOOST_PARAMETER_FUNCTION_FWD_COMBINATIONS(args) \ Chris@16: ) \ Chris@16: /**/ Chris@16: Chris@16: # define BOOST_PARAMETER_CONSTRUCTOR(class_, base, tag_namespace, args) \ Chris@16: BOOST_PARAMETER_CONSTRUCTOR_AUX( \ Chris@16: class_, base, tag_namespace \ Chris@16: , BOOST_PARAMETER_FLATTEN(2, 2, 3, args) \ Chris@16: ) Chris@16: /**/ Chris@16: Chris@16: # ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING Chris@16: # define BOOST_PARAMETER_FUNCTION_FWD_COMBINATION(r, _, i, elem) \ Chris@16: (BOOST_PP_IF( \ Chris@16: BOOST_PARAMETER_FUNCTION_IS_KEYWORD_QUALIFIER( \ Chris@16: BOOST_PARAMETER_FN_ARG_NAME(elem) \ Chris@16: ) \ Chris@16: , (const ParameterArgumentType ## i)(ParameterArgumentType ## i) \ Chris@16: , (const ParameterArgumentType ## i) \ Chris@16: )) Chris@16: // MSVC6.5 lets us bind rvalues to T&. Chris@16: # elif BOOST_WORKAROUND(BOOST_MSVC, < 1300) Chris@16: # define BOOST_PARAMETER_FUNCTION_FWD_COMBINATION(r, _, i, elem) \ Chris@16: (BOOST_PP_IF( \ Chris@16: BOOST_PARAMETER_FUNCTION_IS_KEYWORD_QUALIFIER( \ Chris@16: BOOST_PARAMETER_FN_ARG_NAME(elem) \ Chris@16: ) \ Chris@16: , (ParameterArgumentType ## i) \ Chris@16: , (const ParameterArgumentType ## i) \ Chris@16: )) Chris@16: // No partial ordering. This feature doesn't work. Chris@16: // This is exactly the same as for VC6.5, but we might change it later. Chris@16: # else Chris@16: # define BOOST_PARAMETER_FUNCTION_FWD_COMBINATION(r, _, i, elem) \ Chris@16: (BOOST_PP_IF( \ Chris@16: BOOST_PARAMETER_FUNCTION_IS_KEYWORD_QUALIFIER( \ Chris@16: BOOST_PARAMETER_FN_ARG_NAME(elem) \ Chris@16: ) \ Chris@16: , (ParameterArgumentType ## i) \ Chris@16: , (const ParameterArgumentType ## i) \ Chris@16: )) Chris@16: # endif Chris@16: Chris@16: # define BOOST_PARAMETER_FUNCTION_FWD_COMBINATIONS(args) \ Chris@16: BOOST_PP_SEQ_FOR_EACH_I(BOOST_PARAMETER_FUNCTION_FWD_COMBINATION, ~, args) Chris@16: Chris@16: #endif // BOOST_PARAMETER_PREPROCESSOR_060206_HPP Chris@16: