This class represents a delegate, that is a compound of an object reference and a member function pointer. The generic type of a delegate just depends on the signature of the (member) function pointer but not on the type of the object on which the member function pointer is invoked.
More...
#include <delegate.hxx>
|
static delegate | create (R(*const pFunction)(A...)) |
| Creates a delegate from a static function. More...
|
|
template<class C > |
static delegate | create (C *pObject, R(C::*pMethod)(A...)) noexcept |
| Creates a delegate from a member function and object pointer. More...
|
|
template<class C > |
static delegate | create (C &object, R(C::*pMethod)(A...)) noexcept |
| Creates a delegate from a member function and object reference. More...
|
|
template<class C > |
static delegate | create (const C *pObject, R(C::*pMethod)(A...) const) noexcept |
| Creates a delegate from a const member function and const object pointer. More...
|
|
template<class C > |
static delegate | create (const C &object, R(C::*pMethod)(A...) const) noexcept |
| Creates a delegate from a const member function and const object reference. More...
|
|
static delegate | create (std::function< R(A...)> &&f) |
| Creates a delegate from a lambda expression or std::function . More...
|
|
static delegate | create (const std::function< R(A...)> &f) |
| Creates a delegate from a lambda expression or std::function . More...
|
|
template<class R, class ... A>
class Arp::delegate< R(A...)>
This class represents a delegate, that is a compound of an object reference and a member function pointer. The generic type of a delegate just depends on the signature of the (member) function pointer but not on the type of the object on which the member function pointer is invoked.
A delegate might be seen as a generalized function pointer (callback) in OOP design. It might invoke the following callable targets:
-
static functions
-
member functions
-
lambda expressions
-
std::function
The make_delegate function shall be used to create delegates from these callable targets.
◆ delegate() [1/5]
template<class R , class ... A>
template<class Lambda >
Arp::delegate< R(A...)>::delegate |
( |
Lambda |
f | ) |
|
|
inline |
Constructs a delegate through a lambda expression implicitly.
◆ delegate() [2/5]
template<class R , class ... A>
Arp::delegate< R(A...)>::delegate |
( |
void |
| ) |
|
|
default |
◆ delegate() [3/5]
template<class R , class ... A>
Arp::delegate< R(A...)>::delegate |
( |
const delegate< R(A...)> & |
arg | ) |
|
|
default |
The default copy constructor.
- Parameters
-
◆ delegate() [4/5]
template<class R , class ... A>
Arp::delegate< R(A...)>::delegate |
( |
delegate< R(A...)> && |
arg | ) |
|
|
defaultnoexcept |
The default move constructor.
- Parameters
-
◆ delegate() [5/5]
template<class R , class ... A>
Arp::delegate< R(A...)>::delegate |
( |
std::nullptr_t |
| ) |
|
|
inlinenoexcept |
Constructs an empty delegate representing a nullptr
.
◆ create() [1/7]
template<class R , class ... A>
template<class C >
static delegate Arp::delegate< R(A...)>::create |
( |
C & |
object, |
|
|
R(C::*)(A...) |
pMethod |
|
) |
| |
|
inlinestaticnoexcept |
Creates a delegate from a member function and object reference.
- Parameters
-
pMethod | The member function to invoke. |
object | The object to invoke the member function on. |
- Returns
- A new delegate instance created by the arguments.
◆ create() [2/7]
template<class R , class ... A>
template<class C >
static delegate Arp::delegate< R(A...)>::create |
( |
C * |
pObject, |
|
|
R(C::*)(A...) |
pMethod |
|
) |
| |
|
inlinestaticnoexcept |
Creates a delegate from a member function and object pointer.
- Parameters
-
pMethod | The member function to invoke. |
pObject | The object pointer to invoke the member function on. |
- Returns
- A new delegate instance created by the arguments.
◆ create() [3/7]
template<class R , class ... A>
template<class C >
static delegate Arp::delegate< R(A...)>::create |
( |
const C & |
object, |
|
|
R(C::*)(A...) const |
pMethod |
|
) |
| |
|
inlinestaticnoexcept |
Creates a delegate from a const member function and const object reference.
- Parameters
-
pMethod | The member function to invoke. |
object | The object to invoke the member function on. |
- Returns
- A new delegate instance created by the arguments.
◆ create() [4/7]
template<class R , class ... A>
template<class C >
static delegate Arp::delegate< R(A...)>::create |
( |
const C * |
pObject, |
|
|
R(C::*)(A...) const |
pMethod |
|
) |
| |
|
inlinestaticnoexcept |
Creates a delegate from a const member function and const object pointer.
- Parameters
-
pMethod | The member function to invoke. |
pObject | The object pointer to invoke the member function on. |
- Returns
- A new delegate instance created by the arguments.
◆ create() [5/7]
template<class R , class ... A>
static delegate Arp::delegate< R(A...)>::create |
( |
const std::function< R(A...)> & |
f | ) |
|
|
inlinestatic |
Creates a delegate from a lambda expression or std::function
.
- Parameters
-
- Returns
- A new delegate instance created by the arguments.
◆ create() [6/7]
template<class R , class ... A>
static delegate Arp::delegate< R(A...)>::create |
( |
R(*)(A...) |
pFunction | ) |
|
|
inlinestatic |
Creates a delegate from a static function.
- Parameters
-
pFunction | The static function to invoke. |
- Returns
- A new delegate instance created by the arguments.
◆ create() [7/7]
template<class R , class ... A>
static delegate Arp::delegate< R(A...)>::create |
( |
std::function< R(A...)> && |
f | ) |
|
|
inlinestatic |
Creates a delegate from a lambda expression or std::function
.
- Parameters
-
- Returns
- A new delegate instance created by the arguments.
◆ is_lambda()
template<class R , class ... A>
bool Arp::delegate< R(A...)>::is_lambda |
( |
void |
| ) |
const |
|
inline |
Determines if this instance wraps a lamda expression or std::function
- Returns
true
if this instance is a lambda expression, otherwise false
◆ operator bool()
template<class R , class ... A>
Arp::delegate< R(A...)>::operator bool |
( |
| ) |
const |
|
inlineexplicitnoexcept |
Converts this instance explicitly to bool
.
- Returns
false
if this instance is empty (nullptr
), otherwise true
◆ operator!=() [1/2]
template<class R , class ... A>
bool Arp::delegate< R(A...)>::operator!= |
( |
const delegate< R(A...)> & |
rhs | ) |
const |
|
inlinenoexcept |
Compares this instance to the as argument passed rhs .
- Parameters
-
rhs | The argument to compare this instance to. |
- Returns
true
if rhs is not equal, otherwise false
◆ operator!=() [2/2]
template<class R , class ... A>
bool Arp::delegate< R(A...)>::operator!= |
( |
std::nullptr_t const |
| ) |
const |
|
inlinenoexcept |
Compares this instance to a nullptr
.
- Returns
true
if nullptr
is not equal, otherwise false
◆ operator()()
template<class R , class ... A>
R Arp::delegate< R(A...)>::operator() |
( |
A... |
args | ) |
const |
|
inline |
The functor operator invokes the adapted callable target.
- Parameters
-
args | The arguments to pass to the callable target with the same signature. |
- Returns
- Returns the result of the invoked target.
◆ operator=() [1/2]
template<class R , class ... A>
The default assign operator.
- Parameters
-
arg | The argument to assign to this instance. |
- Returns
- This instance as reference.
◆ operator=() [2/2]
template<class R , class ... A>
The default move assign operator.
- Parameters
-
arg | The argument to move to this instance. |
- Returns
- This instance as reference.
◆ operator==() [1/2]
template<class R , class ... A>
bool Arp::delegate< R(A...)>::operator== |
( |
const delegate< R(A...)> & |
rhs | ) |
const |
|
inlinenoexcept |
Compares this instance to the as argument passed rhs .
- Parameters
-
rhs | The argument to compare this instance to. |
- Returns
true
if rhs is equal, otherwise false
◆ operator==() [2/2]
template<class R , class ... A>
bool Arp::delegate< R(A...)>::operator== |
( |
std::nullptr_t const |
| ) |
const |
|
inlinenoexcept |
Compares this instance to a nullptr
.
- Returns
true
if nullptr
is equal, otherwise false
◆ reset()
template<class R , class ... A>
void Arp::delegate< R(A...)>::reset |
( |
| ) |
|
|
inline |
Resets this instance.
After resetting this instance, this instance is not invokable any more. if(*this)
will return false
.
The documentation for this class was generated from the following file: