libsigc++  2.99.1
Functions
mem_fun()

mem_fun() is used to convert a pointer to a method to a functor. More...

Functions

template<class T_return , class T_obj , class... T_arg>
decltype(auto) sigc::mem_fun (T_return(T_obj::* _A_func)(T_arg...))
 Creates a functor of type sigc::mem_functor which wraps a method. More...
 
template<class T_return , class T_obj , class T_obj2 , class... T_arg>
decltype(auto) sigc::mem_fun (T_obj* _A_obj, T_return(T_obj2::* _A_func)(T_arg...))
 Creates a functor of type sigc::bound_mem_functor which encapsulates a method and an object instance. More...
 
template<class T_return , class T_obj , class T_obj2 , class... T_arg>
decltype(auto) sigc::mem_fun (T_obj& _A_obj, T_return(T_obj2::* _A_func)(T_arg...))
 Creates a functor of type sigc::bound_mem_functor which encapsulates a method and an object instance. More...
 

Detailed Description

mem_fun() is used to convert a pointer to a method to a functor.

Optionally, a reference or pointer to an object can be bound to the functor.

Note
Only if the object type inherits from sigc::trackable, and the functor returned from mem_fun() is assigned to a sigc::slot, is the functor automatically cleared when the object goes out of scope!

If the member function pointer is to an overloaded type, you must specify the types using template arguments starting with the first argument. It is not necessary to supply the return type.

Example:
struct foo : public sigc::trackable
{
void bar(int) {}
};
foo my_foo;
sigc::slot<void, int> sl = sigc::mem_fun(my_foo, &foo::bar);
// Note: f is not a slot. It will not be invalidated when my_foo is deleted.
auto f = sigc::mem_fun(my_foo, &foo::bar); // Usually not what you want.

For const methods mem_fun() takes a const reference or pointer to an object.

Example:
struct foo : public sigc::trackable
{
void bar(int) const {}
};
const foo my_foo;
sigc::slot<void, int> sl = sigc::mem_fun(my_foo, &foo::bar);

Use mem_fun#() if there is an ambiguity as to the number of arguments.

Example:
struct foo : public sigc::trackable
{
void bar(int) {}
void bar(float) {}
void bar(int, int) {}
};
foo my_foo;
sigc::slot<void, int> sl = sigc::mem_fun1<int>(my_foo, &foo::bar);

Function Documentation

template <class T_return , class T_obj , class... T_arg>
decltype(auto) sigc::mem_fun ( T_return(T_obj::*)(T_arg...)  _A_func)
inline

Creates a functor of type sigc::mem_functor which wraps a method.

Creates a functor of type sigc::const_volatile_mem_functor which wraps a const volatile method.

Creates a functor of type sigc::volatile_mem_functor which wraps a volatile method.

Creates a functor of type sigc::const_mem_functor which wraps a const method.

Parameters
_A_funcPointer to method that should be wrapped.
Returns
Functor that executes _A_func on invokation.
template <class T_return , class T_obj , class T_obj2 , class... T_arg>
decltype(auto) sigc::mem_fun ( T_obj *  _A_obj,
T_return(T_obj2::*)(T_arg...)  _A_func 
)
inline

Creates a functor of type sigc::bound_mem_functor which encapsulates a method and an object instance.

Creates a functor of type sigc::bound_const_volatile_mem_functor which encapsulates a method and an object instance.

Creates a functor of type sigc::bound_volatile_mem_functor which encapsulates a method and an object instance.

Creates a functor of type sigc::bound_const_mem_functor which encapsulates a method and an object instance.

Parameters
_A_objPointer to object instance the functor should operate on.
_A_funcPointer to method that should be wrapped.
Returns
Functor that executes _A_func on invokation.
template <class T_return , class T_obj , class T_obj2 , class... T_arg>
decltype(auto) sigc::mem_fun ( T_obj &  _A_obj,
T_return(T_obj2::*)(T_arg...)  _A_func 
)
inline

Creates a functor of type sigc::bound_mem_functor which encapsulates a method and an object instance.

Creates a functor of type sigc::bound_const_volatile_mem_functor which encapsulates a method and an object instance.

Creates a functor of type sigc::bound_volatile_mem_functor which encapsulates a method and an object instance.

Creates a functor of type sigc::bound_const_mem_functor which encapsulates a method and an object instance.

Parameters
_A_objReference to object instance the functor should operate on.
_A_funcPointer to method that should be wrapped.
Returns
Functor that executes _A_func on invokation.