123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330 |
- #if !BOOST_PP_IS_ITERATING
- # ifndef BOOST_LOCAL_FUNCTION_AUX_FUNCTION_HPP_
- # define BOOST_LOCAL_FUNCTION_AUX_FUNCTION_HPP_
- # include <boost/local_function/config.hpp>
- # include <boost/local_function/aux_/member.hpp>
- # include <boost/call_traits.hpp>
- # include <boost/typeof/typeof.hpp>
- # include <boost/config.hpp>
- # include <boost/preprocessor/iteration/iterate.hpp>
- # include <boost/preprocessor/repetition/repeat.hpp>
- # include <boost/preprocessor/repetition/enum.hpp>
- # include <boost/preprocessor/punctuation/comma_if.hpp>
- # include <boost/preprocessor/arithmetic/add.hpp>
- # include <boost/preprocessor/arithmetic/sub.hpp>
- # include <boost/preprocessor/arithmetic/inc.hpp>
- # include <boost/preprocessor/control/iif.hpp>
- # include <boost/preprocessor/cat.hpp>
- #define BOOST_LOCAL_FUNCTION_AUX_FUNCTION_THIS_FILE_ \
- "boost/local_function/aux_/function.hpp"
- #define BOOST_LOCAL_FUNCTION_AUX_FUNCTION_INIT_CALL_FUNC \
- BOOST_LOCAL_FUNCTION_AUX_SYMBOL( (init_call) )
- #define BOOST_LOCAL_FUNCTION_AUX_typename_seq(z, n, unused) \
- (typename)
- #define BOOST_LOCAL_FUNCTION_AUX_arg_type(z, arg_n, unused) \
- BOOST_PP_CAT(Arg, arg_n)
- #define BOOST_LOCAL_FUNCTION_AUX_arg_typedef(z, arg_n, unused) \
- typedef \
- BOOST_LOCAL_FUNCTION_AUX_arg_type(z, arg_n, ~) \
- \
- BOOST_PP_CAT(BOOST_PP_CAT(arg, BOOST_PP_INC(arg_n)), _type) \
- ;
- #define BOOST_LOCAL_FUNCTION_AUX_comma_arg_tparam(z, arg_n, unused) \
- , typename BOOST_LOCAL_FUNCTION_AUX_arg_type(z, arg_n, ~)
- #define BOOST_LOCAL_FUNCTION_AUX_arg_param_type(z, arg_n, comma01) \
- BOOST_PP_COMMA_IF(comma01) \
- typename ::boost::call_traits< \
- BOOST_LOCAL_FUNCTION_AUX_arg_type(z, arg_n, ~) \
- >::param_type
- #define BOOST_LOCAL_FUNCTION_AUX_arg_name(z, arg_n, comma01) \
- BOOST_PP_COMMA_IF(comma01) \
- BOOST_PP_CAT(arg, arg_n)
- #define BOOST_LOCAL_FUNCTION_AUX_arg_param_decl(z, arg_n, unused) \
- BOOST_LOCAL_FUNCTION_AUX_arg_param_type(z, arg_n, 0 )\
- BOOST_LOCAL_FUNCTION_AUX_arg_name(z, arg_n, 0 )
- #define BOOST_LOCAL_FUNCTION_AUX_bind_type(z, bind_n, unused) \
- BOOST_PP_CAT(Bind, bind_n)
- #define BOOST_LOCAL_FUNCTION_AUX_comma_bind_type(z, bind_n, unused) \
- , BOOST_LOCAL_FUNCTION_AUX_bind_type(z, bind_n, ~)
- #define BOOST_LOCAL_FUNCTION_AUX_comma_bind_ref(z, bind_n, unused) \
- , BOOST_LOCAL_FUNCTION_AUX_bind_type(z, bind_n, ~) &
- #define BOOST_LOCAL_FUNCTION_AUX_comma_bind_tparam(z, bind_n, unused) \
- , typename BOOST_LOCAL_FUNCTION_AUX_bind_type(z, bind_n, ~)
- #define BOOST_LOCAL_FUNCTION_AUX_bind_name(z, bind_n, unused) \
- BOOST_PP_CAT(bing, bind_n)
- #define BOOST_LOCAL_FUNCTION_AUX_comma_bind_param_decl(z, bind_n, unused) \
- , \
- BOOST_LOCAL_FUNCTION_AUX_bind_type(z, bind_n, ~) & \
- BOOST_LOCAL_FUNCTION_AUX_bind_name(z, bind_n, ~)
-
- #define BOOST_LOCAL_FUNCTION_AUX_bind_member(z, bind_n, unsued) \
- BOOST_PP_CAT(BOOST_LOCAL_FUNCTION_AUX_bind_name(z, bind_n, ~), _)
- #define BOOST_LOCAL_FUNCTION_AUX_comma_bind_member_deref(z, bind_n, unsued) \
- , member_deref< BOOST_LOCAL_FUNCTION_AUX_bind_type(z, bind_n, ~) >( \
- BOOST_LOCAL_FUNCTION_AUX_bind_member(z, bind_n, ~))
- #define BOOST_LOCAL_FUNCTION_AUX_bind_member_init(z, bind_n, unused) \
- BOOST_LOCAL_FUNCTION_AUX_bind_member(z, bind_n, ~) = member_addr( \
- BOOST_LOCAL_FUNCTION_AUX_bind_name(z, bind_n, ~));
- #define BOOST_LOCAL_FUNCTION_AUX_bind_member_decl(z, bind_n, unused) \
- \
- typename member_type< \
- BOOST_LOCAL_FUNCTION_AUX_bind_type(z, bind_n, ~) \
- >::pointer BOOST_LOCAL_FUNCTION_AUX_bind_member(z, bind_n, ~) ;
- #define BOOST_LOCAL_FUNCTION_AUX_call_ptr(z, n, unused) \
- BOOST_PP_CAT(call_ptr, n)
- #define BOOST_LOCAL_FUNCTION_AUX_call_name(z, n, unused) \
- BOOST_PP_CAT(call, n)
- #define BOOST_LOCAL_FUNCTION_AUX_call_member(z, n, unused) \
- BOOST_PP_CAT(BOOST_LOCAL_FUNCTION_AUX_call_name(z, n, unused), _)
- #define BOOST_LOCAL_FUNCTION_AUX_call_typedef(z, n, arity) \
- typedef R (*BOOST_LOCAL_FUNCTION_AUX_call_ptr(z, n, ~))( \
- object_ptr \
- BOOST_PP_IIF(BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS, \
- BOOST_PP_TUPLE_EAT(3) \
- , \
- BOOST_PP_REPEAT_ ## z \
- )(BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX, \
- BOOST_LOCAL_FUNCTION_AUX_comma_bind_ref, ~) \
- BOOST_PP_REPEAT_ ## z(BOOST_PP_SUB(arity, n), \
- BOOST_LOCAL_FUNCTION_AUX_arg_param_type, 1 )\
- );
- #define BOOST_LOCAL_FUNCTION_AUX_comma_call_param_decl(z, n, unused) \
- , \
- BOOST_LOCAL_FUNCTION_AUX_call_ptr(z, n, ~) \
- BOOST_LOCAL_FUNCTION_AUX_call_name(z, n, ~)
- #define BOOST_LOCAL_FUNCTION_AUX_call_decl(z, n, unused) \
- BOOST_LOCAL_FUNCTION_AUX_call_ptr(z, n, ~) \
- BOOST_LOCAL_FUNCTION_AUX_call_member(z, n, ~);
- #define BOOST_LOCAL_FUNCTION_AUX_call_init(z, n, unused) \
- BOOST_LOCAL_FUNCTION_AUX_call_member(z, n, ~) = \
- BOOST_LOCAL_FUNCTION_AUX_call_name(z, n, ~);
-
- #define BOOST_LOCAL_FUNCTION_AUX_operator_call(z, defaults_n, arity) \
- \
- inline R operator()( \
- BOOST_PP_ENUM_ ## z(BOOST_PP_SUB(arity, defaults_n), \
- BOOST_LOCAL_FUNCTION_AUX_arg_param_decl, ~) \
- ) { \
- \
- \
- \
- \
- \
- \
- \
- return BOOST_LOCAL_FUNCTION_AUX_call_member(z, defaults_n, ~)( \
- object_ \
- BOOST_PP_IIF( \
- BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS,\
- BOOST_PP_TUPLE_EAT(3) \
- , \
- BOOST_PP_REPEAT_ ## z \
- )(BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX, \
- BOOST_LOCAL_FUNCTION_AUX_comma_bind_member_deref, ~) \
- BOOST_PP_REPEAT_ ## z(BOOST_PP_SUB(arity, defaults_n), \
- BOOST_LOCAL_FUNCTION_AUX_arg_name, 1 ) \
- ); \
- }
- namespace boost { namespace local_function { namespace aux {
- template<
- typename F
- , size_t defaults
- #if !BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS
- BOOST_PP_REPEAT(BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX,
- BOOST_LOCAL_FUNCTION_AUX_comma_bind_tparam, ~)
- #endif
- >
- class function {};
- # define BOOST_PP_ITERATION_PARAMS_1 \
- (3, (0, BOOST_LOCAL_FUNCTION_CONFIG_FUNCTION_ARITY_MAX, \
- BOOST_LOCAL_FUNCTION_AUX_FUNCTION_THIS_FILE_))
- # include BOOST_PP_ITERATE() // Iterate over function arity.
- } } }
- #include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
- BOOST_TYPEOF_REGISTER_TEMPLATE(boost::local_function::aux::function,
- (typename)
- (size_t)
-
- BOOST_PP_IIF(BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS,
- BOOST_PP_TUPLE_EAT(3)
- ,
- BOOST_PP_REPEAT
- )(BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX,
- BOOST_LOCAL_FUNCTION_AUX_typename_seq, ~)
- )
- #undef BOOST_LOCAL_FUNCTION_AUX_typename_seq
- #undef BOOST_LOCAL_FUNCTION_AUX_arg_type
- #undef BOOST_LOCAL_FUNCTION_AUX_arg_typedef
- #undef BOOST_LOCAL_FUNCTION_AUX_comma_arg_tparam
- #undef BOOST_LOCAL_FUNCTION_AUX_arg_param_type
- #undef BOOST_LOCAL_FUNCTION_AUX_arg_name
- #undef BOOST_LOCAL_FUNCTION_AUX_arg_param_decl
- #undef BOOST_LOCAL_FUNCTION_AUX_bind_type
- #undef BOOST_LOCAL_FUNCTION_AUX_comma_bind_type
- #undef BOOST_LOCAL_FUNCTION_AUX_comma_bind_ref
- #undef BOOST_LOCAL_FUNCTION_AUX_comma_bind_tparam
- #undef BOOST_LOCAL_FUNCTION_AUX_bind_name
- #undef BOOST_LOCAL_FUNCTION_AUX_comma_bind_param_decl
- #undef BOOST_LOCAL_FUNCTION_AUX_bind_member
- #undef BOOST_LOCAL_FUNCTION_AUX_comma_bind_member_deref
- #undef BOOST_LOCAL_FUNCTION_AUX_bind_member_init
- #undef BOOST_LOCAL_FUNCTION_AUX_bind_member_decl
- #undef BOOST_LOCAL_FUNCTION_AUX_call_ptr
- #undef BOOST_LOCAL_FUNCTION_AUX_call_name
- #undef BOOST_LOCAL_FUNCTION_AUX_call_member
- #undef BOOST_LOCAL_FUNCTION_AUX_call_typedef
- #undef BOOST_LOCAL_FUNCTION_AUX_comma_call_param_decl
- #undef BOOST_LOCAL_FUNCTION_AUX_call_decl
- #undef BOOST_LOCAL_FUNCTION_AUX_call_init
- #undef BOOST_LOCAL_FUNCTION_AUX_operator_call
- # endif
- #elif BOOST_PP_ITERATION_DEPTH() == 1
- # define BOOST_LOCAL_FUNCTION_AUX_arity BOOST_PP_FRAME_ITERATION(1)
- # define BOOST_PP_ITERATION_PARAMS_2 \
- (3, (0, BOOST_LOCAL_FUNCTION_AUX_arity, \
- BOOST_LOCAL_FUNCTION_AUX_FUNCTION_THIS_FILE_))
- # include BOOST_PP_ITERATE() // Iterate over default params count.
- # undef BOOST_LOCAL_FUNCTION_AUX_arity
- #elif BOOST_PP_ITERATION_DEPTH() == 2
- # define BOOST_LOCAL_FUNCTION_AUX_defaults BOOST_PP_FRAME_ITERATION(2)
- template<
- typename R
- BOOST_PP_REPEAT(BOOST_LOCAL_FUNCTION_AUX_arity,
- BOOST_LOCAL_FUNCTION_AUX_comma_arg_tparam, ~)
- #if !BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS
- BOOST_PP_REPEAT(BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX,
- BOOST_LOCAL_FUNCTION_AUX_comma_bind_tparam, ~)
- #endif
- >
- class function<
- R (
- BOOST_PP_ENUM(BOOST_LOCAL_FUNCTION_AUX_arity,
- BOOST_LOCAL_FUNCTION_AUX_arg_type, ~)
- )
- , BOOST_LOCAL_FUNCTION_AUX_defaults
- #if !BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS
- BOOST_PP_REPEAT(BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX,
- BOOST_LOCAL_FUNCTION_AUX_comma_bind_type, ~)
- #endif
- > {
-
-
-
-
-
-
-
-
-
-
-
- typedef void* object_ptr;
- BOOST_PP_REPEAT(BOOST_PP_INC(BOOST_LOCAL_FUNCTION_AUX_defaults),
- BOOST_LOCAL_FUNCTION_AUX_call_typedef,
- BOOST_LOCAL_FUNCTION_AUX_arity)
- public:
-
-
- BOOST_STATIC_CONSTANT(size_t, arity = BOOST_LOCAL_FUNCTION_AUX_arity);
- typedef R result_type;
- BOOST_PP_REPEAT(BOOST_LOCAL_FUNCTION_AUX_arity,
- BOOST_LOCAL_FUNCTION_AUX_arg_typedef, ~)
-
-
-
-
- inline void BOOST_LOCAL_FUNCTION_AUX_FUNCTION_INIT_CALL_FUNC(
- object_ptr object
- #if !BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS
- BOOST_PP_REPEAT(BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX,
- BOOST_LOCAL_FUNCTION_AUX_comma_bind_param_decl, ~)
- #endif
- BOOST_PP_REPEAT(BOOST_PP_INC(BOOST_LOCAL_FUNCTION_AUX_defaults),
- BOOST_LOCAL_FUNCTION_AUX_comma_call_param_decl, ~)
- ) {
- object_ = object;
- #if !BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS
- BOOST_PP_REPEAT(BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX,
- BOOST_LOCAL_FUNCTION_AUX_bind_member_init, ~)
- #endif
- BOOST_PP_REPEAT(BOOST_PP_INC(BOOST_LOCAL_FUNCTION_AUX_defaults),
- BOOST_LOCAL_FUNCTION_AUX_call_init, ~)
- unused_ = 0;
- }
-
-
-
-
- BOOST_PP_REPEAT(BOOST_PP_INC(BOOST_LOCAL_FUNCTION_AUX_defaults),
- BOOST_LOCAL_FUNCTION_AUX_operator_call,
- BOOST_LOCAL_FUNCTION_AUX_arity)
- private:
- object_ptr object_;
- #if !BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS
- BOOST_PP_REPEAT(BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX,
- BOOST_LOCAL_FUNCTION_AUX_bind_member_decl, ~)
- #endif
- BOOST_PP_REPEAT(BOOST_PP_INC(BOOST_LOCAL_FUNCTION_AUX_defaults),
- BOOST_LOCAL_FUNCTION_AUX_call_decl, ~)
-
-
- void* unused_;
- };
- # undef BOOST_LOCAL_FUNCTION_AUX_defaults
- #endif
|