forked from boostorg/function
Fix BOOST_NO_VOID_RETURNS workaround
[SVN r26518]
This commit is contained in:
@ -61,6 +61,14 @@
|
|||||||
#define BOOST_FUNCTION_GET_STATELESS_FUNCTION_OBJ_INVOKER \
|
#define BOOST_FUNCTION_GET_STATELESS_FUNCTION_OBJ_INVOKER \
|
||||||
BOOST_JOIN(get_stateless_function_obj_invoker,BOOST_FUNCTION_NUM_ARGS)
|
BOOST_JOIN(get_stateless_function_obj_invoker,BOOST_FUNCTION_NUM_ARGS)
|
||||||
|
|
||||||
|
#ifndef BOOST_NO_VOID_RETURNS
|
||||||
|
# define BOOST_FUNCTION_VOID_RETURN_TYPE void
|
||||||
|
# define BOOST_FUNCTION_RETURN(X) X
|
||||||
|
#else
|
||||||
|
# define BOOST_FUNCTION_VOID_RETURN_TYPE ::boost::detail::function::unusable
|
||||||
|
# define BOOST_FUNCTION_RETURN(X) X; return BOOST_FUNCTION_VOID_RETURN_TYPE ()
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
namespace detail {
|
namespace detail {
|
||||||
namespace function {
|
namespace function {
|
||||||
@ -86,13 +94,13 @@ namespace boost {
|
|||||||
>
|
>
|
||||||
struct BOOST_FUNCTION_VOID_FUNCTION_INVOKER
|
struct BOOST_FUNCTION_VOID_FUNCTION_INVOKER
|
||||||
{
|
{
|
||||||
static unusable invoke(any_pointer function_ptr BOOST_FUNCTION_COMMA
|
static BOOST_FUNCTION_VOID_RETURN_TYPE
|
||||||
BOOST_FUNCTION_PARMS)
|
invoke(any_pointer function_ptr BOOST_FUNCTION_COMMA
|
||||||
|
BOOST_FUNCTION_PARMS)
|
||||||
|
|
||||||
{
|
{
|
||||||
FunctionPtr f = reinterpret_cast<FunctionPtr>(function_ptr.func_ptr);
|
FunctionPtr f = reinterpret_cast<FunctionPtr>(function_ptr.func_ptr);
|
||||||
f(BOOST_FUNCTION_ARGS);
|
BOOST_FUNCTION_RETURN(f(BOOST_FUNCTION_ARGS));
|
||||||
return unusable();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -119,14 +127,13 @@ namespace boost {
|
|||||||
>
|
>
|
||||||
struct BOOST_FUNCTION_VOID_FUNCTION_OBJ_INVOKER
|
struct BOOST_FUNCTION_VOID_FUNCTION_OBJ_INVOKER
|
||||||
{
|
{
|
||||||
static unusable invoke(any_pointer function_obj_ptr
|
static BOOST_FUNCTION_VOID_RETURN_TYPE
|
||||||
BOOST_FUNCTION_COMMA
|
invoke(any_pointer function_obj_ptr BOOST_FUNCTION_COMMA
|
||||||
BOOST_FUNCTION_PARMS)
|
BOOST_FUNCTION_PARMS)
|
||||||
|
|
||||||
{
|
{
|
||||||
FunctionObj* f = (FunctionObj*)(function_obj_ptr.obj_ptr);
|
FunctionObj* f = (FunctionObj*)(function_obj_ptr.obj_ptr);
|
||||||
(*f)(BOOST_FUNCTION_ARGS);
|
BOOST_FUNCTION_RETURN((*f)(BOOST_FUNCTION_ARGS));
|
||||||
return unusable();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -151,13 +158,12 @@ namespace boost {
|
|||||||
>
|
>
|
||||||
struct BOOST_FUNCTION_STATELESS_VOID_FUNCTION_OBJ_INVOKER
|
struct BOOST_FUNCTION_STATELESS_VOID_FUNCTION_OBJ_INVOKER
|
||||||
{
|
{
|
||||||
static unusable invoke(any_pointer BOOST_FUNCTION_COMMA
|
static BOOST_FUNCTION_VOID_RETURN_TYPE
|
||||||
BOOST_FUNCTION_PARMS)
|
invoke(any_pointer BOOST_FUNCTION_COMMA BOOST_FUNCTION_PARMS)
|
||||||
|
|
||||||
{
|
{
|
||||||
FunctionObj f = FunctionObj();
|
FunctionObj f = FunctionObj();
|
||||||
f(BOOST_FUNCTION_ARGS);
|
BOOST_FUNCTION_RETURN(f(BOOST_FUNCTION_ARGS));
|
||||||
return unusable();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -235,8 +241,12 @@ namespace boost {
|
|||||||
class BOOST_FUNCTION_FUNCTION : public function_base
|
class BOOST_FUNCTION_FUNCTION : public function_base
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef typename detail::function::function_return_type<R>::type
|
#ifndef BOOST_NO_VOID_RETURNS
|
||||||
internal_result_type;
|
typedef R result_type;
|
||||||
|
#else
|
||||||
|
typedef typename detail::function::function_return_type<R>::type
|
||||||
|
result_type;
|
||||||
|
#endif // BOOST_NO_VOID_RETURNS
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct clear_type {};
|
struct clear_type {};
|
||||||
@ -248,7 +258,7 @@ namespace boost {
|
|||||||
template<typename Args>
|
template<typename Args>
|
||||||
struct sig
|
struct sig
|
||||||
{
|
{
|
||||||
typedef internal_result_type type;
|
typedef result_type type;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if BOOST_FUNCTION_NUM_ARGS == 1
|
#if BOOST_FUNCTION_NUM_ARGS == 1
|
||||||
@ -261,11 +271,6 @@ namespace boost {
|
|||||||
BOOST_STATIC_CONSTANT(int, arity = BOOST_FUNCTION_NUM_ARGS);
|
BOOST_STATIC_CONSTANT(int, arity = BOOST_FUNCTION_NUM_ARGS);
|
||||||
BOOST_FUNCTION_ARG_TYPES
|
BOOST_FUNCTION_ARG_TYPES
|
||||||
|
|
||||||
#ifndef BOOST_NO_VOID_RETURNS
|
|
||||||
typedef R result_type;
|
|
||||||
#else
|
|
||||||
typedef internal_result_type result_type;
|
|
||||||
#endif // BOOST_NO_VOID_RETURNS
|
|
||||||
typedef Allocator allocator_type;
|
typedef Allocator allocator_type;
|
||||||
typedef BOOST_FUNCTION_FUNCTION self_type;
|
typedef BOOST_FUNCTION_FUNCTION self_type;
|
||||||
|
|
||||||
@ -315,15 +320,7 @@ namespace boost {
|
|||||||
if (this->empty())
|
if (this->empty())
|
||||||
boost::throw_exception(bad_function_call());
|
boost::throw_exception(bad_function_call());
|
||||||
|
|
||||||
internal_result_type result = invoker(this->functor
|
return invoker(this->functor BOOST_FUNCTION_COMMA BOOST_FUNCTION_ARGS);
|
||||||
BOOST_FUNCTION_COMMA
|
|
||||||
BOOST_FUNCTION_ARGS);
|
|
||||||
|
|
||||||
#ifndef BOOST_NO_VOID_RETURNS
|
|
||||||
return static_cast<result_type>(result);
|
|
||||||
#else
|
|
||||||
return result;
|
|
||||||
#endif // BOOST_NO_VOID_RETURNS
|
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
result_type operator()(BOOST_FUNCTION_PARMS) const;
|
result_type operator()(BOOST_FUNCTION_PARMS) const;
|
||||||
@ -539,9 +536,9 @@ namespace boost {
|
|||||||
this->functor = detail::function::make_any_pointer(this);
|
this->functor = detail::function::make_any_pointer(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef internal_result_type (*invoker_type)(detail::function::any_pointer
|
typedef result_type (*invoker_type)(detail::function::any_pointer
|
||||||
BOOST_FUNCTION_COMMA
|
BOOST_FUNCTION_COMMA
|
||||||
BOOST_FUNCTION_TEMPLATE_ARGS);
|
BOOST_FUNCTION_TEMPLATE_ARGS);
|
||||||
|
|
||||||
invoker_type invoker;
|
invoker_type invoker;
|
||||||
};
|
};
|
||||||
@ -573,19 +570,11 @@ namespace boost {
|
|||||||
Allocator>
|
Allocator>
|
||||||
::operator()(BOOST_FUNCTION_PARMS) const
|
::operator()(BOOST_FUNCTION_PARMS) const
|
||||||
{
|
{
|
||||||
if (this->empty())
|
if (this->empty())
|
||||||
boost::throw_exception(bad_function_call());
|
boost::throw_exception(bad_function_call());
|
||||||
|
|
||||||
internal_result_type result = invoker(this->functor
|
return invoker(this->functor BOOST_FUNCTION_COMMA BOOST_FUNCTION_ARGS);
|
||||||
BOOST_FUNCTION_COMMA
|
}
|
||||||
BOOST_FUNCTION_ARGS);
|
|
||||||
|
|
||||||
# ifndef BOOST_NO_VOID_RETURNS
|
|
||||||
return static_cast<result_type>(result);
|
|
||||||
# else
|
|
||||||
return result;
|
|
||||||
# endif // BOOST_NO_VOID_RETURNS
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Poison comparisons between boost::function objects of the same type.
|
// Poison comparisons between boost::function objects of the same type.
|
||||||
@ -719,3 +708,5 @@ public:
|
|||||||
#undef BOOST_FUNCTION_ARGS
|
#undef BOOST_FUNCTION_ARGS
|
||||||
#undef BOOST_FUNCTION_ARG_TYPE
|
#undef BOOST_FUNCTION_ARG_TYPE
|
||||||
#undef BOOST_FUNCTION_ARG_TYPES
|
#undef BOOST_FUNCTION_ARG_TYPES
|
||||||
|
#undef BOOST_FUNCTION_VOID_RETURN_TYPE
|
||||||
|
#undef BOOST_FUNCTION_RETURN
|
||||||
|
Reference in New Issue
Block a user