mirror of
https://github.com/boostorg/function.git
synced 2025-07-25 10:27:14 +02:00
function_template.hpp:
- const function calling semantics changed. Now 'function' has pointer/reference semantics (constness of 'function' object does not affect constness of targetted function object) [SVN r10685]
This commit is contained in:
@ -36,7 +36,6 @@ namespace boost {
|
|||||||
struct BOOST_FUNCTION_INVOKER_BASE
|
struct BOOST_FUNCTION_INVOKER_BASE
|
||||||
{
|
{
|
||||||
virtual ~BOOST_FUNCTION_INVOKER_BASE() {}
|
virtual ~BOOST_FUNCTION_INVOKER_BASE() {}
|
||||||
virtual R call(BOOST_FUNCTION_PARMS) = 0;
|
|
||||||
virtual R call(BOOST_FUNCTION_PARMS) const = 0;
|
virtual R call(BOOST_FUNCTION_PARMS) const = 0;
|
||||||
virtual BOOST_FUNCTION_INVOKER_BASE* clone() const = 0;
|
virtual BOOST_FUNCTION_INVOKER_BASE* clone() const = 0;
|
||||||
virtual void destroy(BOOST_FUNCTION_INVOKER_BASE*) = 0;
|
virtual void destroy(BOOST_FUNCTION_INVOKER_BASE*) = 0;
|
||||||
@ -63,11 +62,6 @@ namespace boost {
|
|||||||
explicit BOOST_FUNCTION_FUNCTION_INVOKER(FunctionPtr f) :
|
explicit BOOST_FUNCTION_FUNCTION_INVOKER(FunctionPtr f) :
|
||||||
function_ptr(f) {}
|
function_ptr(f) {}
|
||||||
|
|
||||||
virtual R call(BOOST_FUNCTION_PARMS)
|
|
||||||
{
|
|
||||||
return function_ptr(BOOST_FUNCTION_ARGS);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual R call(BOOST_FUNCTION_PARMS) const
|
virtual R call(BOOST_FUNCTION_PARMS) const
|
||||||
{
|
{
|
||||||
return function_ptr(BOOST_FUNCTION_ARGS);
|
return function_ptr(BOOST_FUNCTION_ARGS);
|
||||||
@ -115,8 +109,7 @@ namespace boost {
|
|||||||
private:
|
private:
|
||||||
FunctionPtr function_ptr;
|
FunctionPtr function_ptr;
|
||||||
#else
|
#else
|
||||||
static R invoke(any_pointer function_ptr,
|
static R invoke(any_pointer function_ptr BOOST_FUNCTION_COMMA
|
||||||
bool BOOST_FUNCTION_COMMA
|
|
||||||
BOOST_FUNCTION_PARMS)
|
BOOST_FUNCTION_PARMS)
|
||||||
{
|
{
|
||||||
FunctionPtr f = reinterpret_cast<FunctionPtr>(function_ptr.func_ptr);
|
FunctionPtr f = reinterpret_cast<FunctionPtr>(function_ptr.func_ptr);
|
||||||
@ -145,12 +138,6 @@ namespace boost {
|
|||||||
explicit BOOST_FUNCTION_VOID_FUNCTION_INVOKER(FunctionPtr f) :
|
explicit BOOST_FUNCTION_VOID_FUNCTION_INVOKER(FunctionPtr f) :
|
||||||
function_ptr(f) {}
|
function_ptr(f) {}
|
||||||
|
|
||||||
virtual unusable call(BOOST_FUNCTION_PARMS)
|
|
||||||
{
|
|
||||||
function_ptr(BOOST_FUNCTION_ARGS);
|
|
||||||
return unusable();
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual unusable call(BOOST_FUNCTION_PARMS) const
|
virtual unusable call(BOOST_FUNCTION_PARMS) const
|
||||||
{
|
{
|
||||||
function_ptr(BOOST_FUNCTION_ARGS);
|
function_ptr(BOOST_FUNCTION_ARGS);
|
||||||
@ -199,8 +186,7 @@ namespace boost {
|
|||||||
private:
|
private:
|
||||||
FunctionPtr function_ptr;
|
FunctionPtr function_ptr;
|
||||||
# else
|
# else
|
||||||
static unusable invoke(any_pointer function_ptr,
|
static unusable invoke(any_pointer function_ptr BOOST_FUNCTION_COMMA
|
||||||
bool BOOST_FUNCTION_COMMA
|
|
||||||
BOOST_FUNCTION_PARMS)
|
BOOST_FUNCTION_PARMS)
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -231,11 +217,6 @@ namespace boost {
|
|||||||
explicit BOOST_FUNCTION_FUNCTION_OBJ_INVOKER(const FunctionObj& f) :
|
explicit BOOST_FUNCTION_FUNCTION_OBJ_INVOKER(const FunctionObj& f) :
|
||||||
function_obj(f) {}
|
function_obj(f) {}
|
||||||
|
|
||||||
virtual R call(BOOST_FUNCTION_PARMS)
|
|
||||||
{
|
|
||||||
return function_obj(BOOST_FUNCTION_ARGS);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual R call(BOOST_FUNCTION_PARMS) const
|
virtual R call(BOOST_FUNCTION_PARMS) const
|
||||||
{
|
{
|
||||||
return function_obj(BOOST_FUNCTION_ARGS);
|
return function_obj(BOOST_FUNCTION_ARGS);
|
||||||
@ -281,21 +262,14 @@ namespace boost {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FunctionObj function_obj;
|
mutable FunctionObj function_obj;
|
||||||
#else
|
#else
|
||||||
static R invoke(any_pointer function_obj_ptr,
|
static R invoke(any_pointer function_obj_ptr BOOST_FUNCTION_COMMA
|
||||||
bool is_const BOOST_FUNCTION_COMMA
|
|
||||||
BOOST_FUNCTION_PARMS)
|
BOOST_FUNCTION_PARMS)
|
||||||
|
|
||||||
{
|
{
|
||||||
FunctionObj* f = static_cast<FunctionObj*>(function_obj_ptr.obj_ptr);
|
FunctionObj* f = static_cast<FunctionObj*>(function_obj_ptr.obj_ptr);
|
||||||
if (is_const) {
|
return (*f)(BOOST_FUNCTION_ARGS);
|
||||||
const FunctionObj* fc = f;
|
|
||||||
return (*fc)(BOOST_FUNCTION_ARGS);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return (*f)(BOOST_FUNCTION_ARGS);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS
|
#endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS
|
||||||
};
|
};
|
||||||
@ -320,12 +294,6 @@ namespace boost {
|
|||||||
explicit BOOST_FUNCTION_VOID_FUNCTION_OBJ_INVOKER(const FunctionObj& f)
|
explicit BOOST_FUNCTION_VOID_FUNCTION_OBJ_INVOKER(const FunctionObj& f)
|
||||||
: function_obj(f) {}
|
: function_obj(f) {}
|
||||||
|
|
||||||
virtual unusable call(BOOST_FUNCTION_PARMS)
|
|
||||||
{
|
|
||||||
function_obj(BOOST_FUNCTION_ARGS);
|
|
||||||
return unusable();
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual unusable call(BOOST_FUNCTION_PARMS) const
|
virtual unusable call(BOOST_FUNCTION_PARMS) const
|
||||||
{
|
{
|
||||||
function_obj(BOOST_FUNCTION_ARGS);
|
function_obj(BOOST_FUNCTION_ARGS);
|
||||||
@ -372,22 +340,15 @@ namespace boost {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FunctionObj function_obj;
|
mutable FunctionObj function_obj;
|
||||||
# else
|
# else
|
||||||
static unusable invoke(any_pointer function_obj_ptr,
|
static unusable invoke(any_pointer function_obj_ptr
|
||||||
bool is_const BOOST_FUNCTION_COMMA
|
BOOST_FUNCTION_COMMA
|
||||||
BOOST_FUNCTION_PARMS)
|
BOOST_FUNCTION_PARMS)
|
||||||
|
|
||||||
{
|
{
|
||||||
FunctionObj* f = static_cast<FunctionObj*>(function_obj_ptr.obj_ptr);
|
FunctionObj* f = static_cast<FunctionObj*>(function_obj_ptr.obj_ptr);
|
||||||
if (is_const) {
|
(*f)(BOOST_FUNCTION_ARGS);
|
||||||
const FunctionObj* fc = f;
|
|
||||||
(*fc)(BOOST_FUNCTION_ARGS);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
(*f)(BOOST_FUNCTION_ARGS);
|
|
||||||
}
|
|
||||||
|
|
||||||
return unusable();
|
return unusable();
|
||||||
}
|
}
|
||||||
# endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS
|
# endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS
|
||||||
@ -525,27 +486,6 @@ namespace boost {
|
|||||||
|
|
||||||
~BOOST_FUNCTION_FUNCTION() { clear(); }
|
~BOOST_FUNCTION_FUNCTION() { clear(); }
|
||||||
|
|
||||||
// Invoke the target
|
|
||||||
result_type operator()(BOOST_FUNCTION_PARMS)
|
|
||||||
{
|
|
||||||
assert(!this->empty());
|
|
||||||
|
|
||||||
policy_type policy;
|
|
||||||
policy.precall(this);
|
|
||||||
|
|
||||||
#ifdef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS
|
|
||||||
impl_type* i = reinterpret_cast<impl_type*>(impl);
|
|
||||||
result_type result = i->call(BOOST_FUNCTION_ARGS);
|
|
||||||
#else
|
|
||||||
result_type result = invoker(functor,
|
|
||||||
false BOOST_FUNCTION_COMMA
|
|
||||||
BOOST_FUNCTION_ARGS);
|
|
||||||
#endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS
|
|
||||||
|
|
||||||
policy.postcall(this);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
result_type operator()(BOOST_FUNCTION_PARMS) const
|
result_type operator()(BOOST_FUNCTION_PARMS) const
|
||||||
{
|
{
|
||||||
assert(!this->empty());
|
assert(!this->empty());
|
||||||
@ -557,8 +497,7 @@ namespace boost {
|
|||||||
const impl_type* i = reinterpret_cast<const impl_type*>(impl);
|
const impl_type* i = reinterpret_cast<const impl_type*>(impl);
|
||||||
result_type result = i->call(BOOST_FUNCTION_ARGS);
|
result_type result = i->call(BOOST_FUNCTION_ARGS);
|
||||||
#else
|
#else
|
||||||
result_type result = invoker(functor,
|
result_type result = invoker(functor BOOST_FUNCTION_COMMA
|
||||||
true BOOST_FUNCTION_COMMA
|
|
||||||
BOOST_FUNCTION_ARGS);
|
BOOST_FUNCTION_ARGS);
|
||||||
#endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS
|
#endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS
|
||||||
|
|
||||||
@ -756,8 +695,8 @@ namespace boost {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifndef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS
|
#ifndef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS
|
||||||
typedef result_type (*invoker_type)(detail::function::any_pointer,
|
typedef result_type (*invoker_type)(detail::function::any_pointer
|
||||||
bool BOOST_FUNCTION_COMMA
|
BOOST_FUNCTION_COMMA
|
||||||
BOOST_FUNCTION_TEMPLATE_ARGS);
|
BOOST_FUNCTION_TEMPLATE_ARGS);
|
||||||
|
|
||||||
invoker_type invoker;
|
invoker_type invoker;
|
||||||
|
Reference in New Issue
Block a user