|
| delegate () noexcept |
| Default constructor.
|
|
template<auto Candidate, typename... Type> |
| delegate (connect_arg_t< Candidate >, Type &&...value_or_instance) noexcept |
| Constructs a delegate with a given object or payload, if any.
|
|
| delegate (function_type *function, const void *payload=nullptr) noexcept |
| Constructs a delegate and connects an user defined function with optional payload.
|
|
template<auto Candidate> |
void | connect () noexcept |
| Connects a free function or an unbound member to a delegate.
|
|
template<auto Candidate, typename Type > |
void | connect (Type &value_or_instance) noexcept |
| Connects a free function with payload or a bound member to a delegate.
|
|
template<auto Candidate, typename Type > |
void | connect (Type *value_or_instance) noexcept |
| Connects a free function with payload or a bound member to a delegate.
|
|
void | connect (function_type *function, const void *payload=nullptr) noexcept |
| Connects an user defined function with optional payload to a delegate.
|
|
void | reset () noexcept |
| Resets a delegate.
|
|
function_type * | target () const noexcept |
| Returns a pointer to the stored callable function target, if any.
|
|
const void * | data () const noexcept |
| Returns the instance or the payload linked to a delegate, if any.
|
|
Ret | operator() (Args... args) const |
| Triggers a delegate.
|
|
| operator bool () const noexcept |
| Checks whether a delegate actually stores a listener.
|
|
bool | operator== (const delegate< Ret(Args...)> &other) const noexcept |
| Compares the contents of two delegates.
|
|
template<typename Ret, typename... Args>
class entt::delegate< Ret(Args...)>
Utility class to use to send around functions and members.
Unmanaged delegate for function pointers and members. Users of this class are in charge of disconnecting instances before deleting them.
A delegate can be used as a general purpose invoker without memory overhead for free functions possibly with payloads and bound or unbound members.
- Template Parameters
-
Ret | Return type of a function type. |
Args | Types of arguments of a function type. |
Definition at line 66 of file delegate.hpp.
template<typename Ret , typename... Args>
template<auto Candidate, typename... Type>
Constructs a delegate with a given object or payload, if any.
- Template Parameters
-
Candidate | Function or member to connect to the delegate. |
Type | Type of class or type of payload, if any. |
- Parameters
-
value_or_instance | Optional valid object that fits the purpose. |
Definition at line 131 of file delegate.hpp.
template<typename Ret , typename... Args>
Connects an user defined function with optional payload to a delegate.
The delegate isn't responsible for the connected object or the payload. Users must always guarantee that the lifetime of an instance overcomes the one of the delegate.
The payload is returned as the first argument to the target function in all cases.
- Parameters
-
function | Function to connect to the delegate. |
payload | User defined arbitrary data. |
Definition at line 230 of file delegate.hpp.
template<typename Ret , typename... Args>
template<auto Candidate, typename Type >
void entt::delegate< Ret(Args...)>::connect |
( |
Type & |
value_or_instance | ) |
|
|
inlinenoexcept |
Connects a free function with payload or a bound member to a delegate.
The delegate isn't responsible for the connected object or the payload. Users must always guarantee that the lifetime of the instance overcomes the one of the delegate.
When used to connect a free function with payload, its signature must be such that the instance is the first argument before the ones used to define the delegate itself.
- Template Parameters
-
Candidate | Function or member to connect to the delegate. |
Type | Type of class or type of payload. |
- Parameters
-
value_or_instance | A valid reference that fits the purpose. |
Definition at line 180 of file delegate.hpp.