mirror of
https://github.com/boostorg/local_function.git
synced 2026-02-21 15:12:26 +00:00
Wrapped a metafunction call into a local struct to try to workaround a problem with add_template on the intel compiler.
[SVN r77820]
This commit is contained in:
@@ -325,8 +325,8 @@ BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_MAYBECONST_BIND_MEMBER_INIT_ENUM_( \
|
||||
|
||||
// Expand to the function type `R (A1, ...)`.
|
||||
#define BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_F_( \
|
||||
id, decl_traits, has_type, function_type) \
|
||||
BOOST_LOCAL_FUNCTION_AUX_CODE_RESULT_TYPE(id) \
|
||||
id, typename01, decl_traits, has_type, function_type) \
|
||||
BOOST_LOCAL_FUNCTION_AUX_CODE_RESULT_TYPE(id, typename01) \
|
||||
BOOST_PP_EXPR_IIF(has_type, (function_type) ) \
|
||||
( \
|
||||
BOOST_PP_LIST_FOR_EACH_I( \
|
||||
@@ -385,7 +385,8 @@ BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_MAYBECONST_BIND_MEMBER_INIT_ENUM_( \
|
||||
#define BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_CALL_(z, defaults_n, \
|
||||
id, typename01, decl_traits, params, \
|
||||
const_binds, has_const_bind_this, binds, has_bind_this) \
|
||||
inline BOOST_LOCAL_FUNCTION_AUX_CODE_RESULT_TYPE(id) operator()( \
|
||||
inline BOOST_LOCAL_FUNCTION_AUX_CODE_RESULT_TYPE(id, typename01) \
|
||||
operator()( \
|
||||
BOOST_PP_LIST_FOR_EACH_I( \
|
||||
BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_PARAM_ARG_DECL_ENUM_, \
|
||||
typename01, params) \
|
||||
@@ -461,7 +462,7 @@ BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_STATIC_CALL_COMMA_BIND_PARAM_DECLS_( \
|
||||
#define BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_STATIC_CALL_(z, defaults_n, \
|
||||
id, typename01, decl_traits, params, \
|
||||
const_binds, has_const_bind_this, binds, has_bind_this) \
|
||||
inline static BOOST_LOCAL_FUNCTION_AUX_CODE_RESULT_TYPE(id) \
|
||||
inline static BOOST_LOCAL_FUNCTION_AUX_CODE_RESULT_TYPE(id, typename01) \
|
||||
BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_STATIC_CALL_FUNC_(z, defaults_n, ~)( \
|
||||
void* object \
|
||||
BOOST_PP_IIF(BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS, \
|
||||
@@ -691,8 +692,8 @@ BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_STATIC_CALL_COMMA_BIND_PARAM_DECLS_( \
|
||||
{ \
|
||||
/* function type */ \
|
||||
typedef \
|
||||
BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_F_(id, decl_traits, \
|
||||
1 /* has type */, \
|
||||
BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_F_(id, typename01, \
|
||||
decl_traits, 1 /* has type */, \
|
||||
BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_F_TYPE_) \
|
||||
; \
|
||||
/* functor type -- this type cannot have ID postfix because it is */ \
|
||||
@@ -721,7 +722,8 @@ BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_STATIC_CALL_COMMA_BIND_PARAM_DECLS_( \
|
||||
/* (traits must be defined in both this and the global functor) */ \
|
||||
enum { arity = ::boost::function_traits< /* can't use static data */ \
|
||||
BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_F_TYPE_ >::arity }; \
|
||||
typedef BOOST_LOCAL_FUNCTION_AUX_CODE_RESULT_TYPE(id) result_type; \
|
||||
typedef BOOST_LOCAL_FUNCTION_AUX_CODE_RESULT_TYPE(id, typename01) \
|
||||
result_type; \
|
||||
BOOST_PP_LIST_FOR_EACH_I( \
|
||||
BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_ARG_TYPEDEF_, \
|
||||
typename01, params) \
|
||||
@@ -791,7 +793,7 @@ BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_STATIC_CALL_COMMA_BIND_PARAM_DECLS_( \
|
||||
/* body function (unfortunately, cannot be static to allow access */ \
|
||||
/* to member var with local function name for recursion but doing */ \
|
||||
/* so also allows the body to misuse `this` instead of `this_`) */ \
|
||||
inline BOOST_LOCAL_FUNCTION_AUX_CODE_RESULT_TYPE(id) \
|
||||
inline BOOST_LOCAL_FUNCTION_AUX_CODE_RESULT_TYPE(id, typename01) \
|
||||
BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_BODY_FUNC_( \
|
||||
/* const binds */ \
|
||||
BOOST_PP_LIST_FOR_EACH_I( \
|
||||
|
||||
@@ -39,8 +39,8 @@
|
||||
#define BOOST_LOCAL_FUNCTION_AUX_CODE_RESULT_PARAMS_(id) \
|
||||
BOOST_LOCAL_FUNCTION_AUX_SYMBOL( (deduce_result_params)(id) )
|
||||
|
||||
#define BOOST_LOCAL_FUNCTION_AUX_CODE_RESULT_FUNC_TYPE_(id) \
|
||||
BOOST_LOCAL_FUNCTION_AUX_SYMBOL( (deduce_result_function_type)(id) )
|
||||
#define BOOST_LOCAL_FUNCTION_AUX_CODE_RESULT_TYPE_(id) \
|
||||
BOOST_LOCAL_FUNCTION_AUX_SYMBOL( (result_type)(id) )
|
||||
|
||||
// User did not explicitly specified result type, deduce it (using Typeof).
|
||||
#define BOOST_LOCAL_FUNCTION_AUX_CODE_RESULT_DEDUCE_( \
|
||||
@@ -70,37 +70,38 @@
|
||||
BOOST_LOCAL_FUNCTION_AUX_CODE_RESULT_CAPTURE_(id) \
|
||||
; \
|
||||
struct BOOST_LOCAL_FUNCTION_AUX_CODE_RESULT_PARAMS_(id) { \
|
||||
/* this typedef is internal to struct so its name will not clash */ \
|
||||
typedef BOOST_LOCAL_FUNCTION_AUX_CODE_RESULT_CAPTURE_(id) \
|
||||
function_ptr; \
|
||||
}; \
|
||||
typedef BOOST_PP_EXPR_IIF(typename01, typename) \
|
||||
::boost::remove_pointer< BOOST_PP_EXPR_IIF(typename01, typename) \
|
||||
BOOST_LOCAL_FUNCTION_AUX_CODE_RESULT_PARAMS_(id)::function_ptr \
|
||||
>::type \
|
||||
BOOST_LOCAL_FUNCTION_AUX_CODE_RESULT_FUNC_TYPE_(id) \
|
||||
; \
|
||||
typedef BOOST_PP_EXPR_IIF(typename01, typename) \
|
||||
::boost::function_traits< \
|
||||
BOOST_LOCAL_FUNCTION_AUX_CODE_RESULT_FUNC_TYPE_(id) \
|
||||
>::result_type \
|
||||
BOOST_LOCAL_FUNCTION_AUX_CODE_RESULT_TYPE(id) \
|
||||
;
|
||||
/* internal to struct to workaround GCC and other compiler's issues */ \
|
||||
typedef \
|
||||
BOOST_PP_EXPR_IIF(typename01, typename) \
|
||||
::boost::function_traits< \
|
||||
BOOST_PP_EXPR_IIF(typename01, typename) \
|
||||
::boost::remove_pointer< \
|
||||
BOOST_LOCAL_FUNCTION_AUX_CODE_RESULT_CAPTURE_(id) \
|
||||
>::type \
|
||||
>::result_type \
|
||||
BOOST_LOCAL_FUNCTION_AUX_CODE_RESULT_TYPE_(id) \
|
||||
; \
|
||||
};
|
||||
|
||||
// Use result type as explicitly specified by user (no type deduction needed).
|
||||
// Precondition: RETURNS(decl_traits) != NIL
|
||||
#define BOOST_LOCAL_FUNCTION_AUX_CODE_RESULT_TYPED_( \
|
||||
id, typename01, decl_traits) \
|
||||
typedef \
|
||||
BOOST_PP_LIST_FIRST(BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_RETURNS( \
|
||||
decl_traits)) \
|
||||
BOOST_LOCAL_FUNCTION_AUX_CODE_RESULT_TYPE(id) \
|
||||
;
|
||||
struct BOOST_LOCAL_FUNCTION_AUX_CODE_RESULT_PARAMS_(id) { \
|
||||
typedef \
|
||||
BOOST_PP_LIST_FIRST( \
|
||||
BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_RETURNS( \
|
||||
decl_traits)) \
|
||||
BOOST_LOCAL_FUNCTION_AUX_CODE_RESULT_TYPE_(id) \
|
||||
; \
|
||||
};
|
||||
|
||||
// PUBLIC //
|
||||
|
||||
#define BOOST_LOCAL_FUNCTION_AUX_CODE_RESULT_TYPE(id) \
|
||||
BOOST_LOCAL_FUNCTION_AUX_SYMBOL( (result_type)(id) )
|
||||
#define BOOST_LOCAL_FUNCTION_AUX_CODE_RESULT_TYPE(id, typename01) \
|
||||
BOOST_PP_EXPR_IIF(typename01, typename) \
|
||||
BOOST_LOCAL_FUNCTION_AUX_CODE_RESULT_PARAMS_(id) :: \
|
||||
BOOST_LOCAL_FUNCTION_AUX_CODE_RESULT_TYPE_(id)
|
||||
|
||||
#define BOOST_LOCAL_FUNCTION_AUX_CODE_RESULT_DECL(id) \
|
||||
/* result type here */ (*BOOST_LOCAL_FUNCTION_AUX_CODE_RESULT_FUNC_(id))();
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE(boost::function, 1)
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE(boost::function1, 2) // Also `functionN`.
|
||||
|
||||
boost::function<int (int)> derivative(boost::function<int (int)>& f, int dx) {
|
||||
int BOOST_LOCAL_FUNCTION(bind& f, const bind dx, int x) {
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE(boost::function, 1)
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE(boost::function1, 2) // Also `functionN`.
|
||||
|
||||
boost::function<int (int)> derivative(boost::function<int (int)>& f, int dx) {
|
||||
int BOOST_LOCAL_FUNCTION( (bind& f) (const bind dx) (int x) ) {
|
||||
|
||||
Reference in New Issue
Block a user