Delegate for function pointers and members. It can be used as a general-purpose invoker for any free function with no memory overhead.
More...
|
| template<auto FuncToBind> |
| | delegate (detail::connect_arg_t< FuncToBind >) noexcept |
| | Constructs a delegate by binding a free function or an unbound member to it.
|
| |
| template<auto FuncToBind, typename Type > |
| | delegate (detail::connect_arg_t< FuncToBind >, Type &&value_or_instance) noexcept |
| | Constructs a delegate by binding a free function with context or a bound member to it.
|
| |
| | delegate (func_type *func, const void *data=nullptr) noexcept |
| | Constructs a delegate by binding a function with optional context to it.
|
| |
| template<auto FuncToBind> |
| void | bind () noexcept |
| | Binds a free function or an unbound member to a delegate.
|
| |
| template<auto FuncToBind, typename Type > |
| void | bind (Type &value_or_instance) noexcept |
| | Binds a free function with context or a bound member to a delegate. When used to bind a ree function with context, its signature must be such that the instance is the first argument before the ones used to define the delegate itself.
|
| |
| template<auto FuncToBind, typename Type > |
| void | bind (Type *value_or_instance) noexcept |
| | Binds a free function with context or a bound member to a delegate.
|
| |
| void | bind (func_type *function, const void *context=nullptr) noexcept |
| | Binds an user defined function with optional context to a delegate. The context is returned as the first argument to the target function in all cases.
|
| |
|
void | reset () noexcept |
| | Resets a delegate. After a reset, a delegate cannot be invoked anymore.
|
| |
| GAIA_NODISCARD bool | has_func () const noexcept |
| | Returns the functor pointer linked to a delegate, if any.
|
| |
| GAIA_NODISCARD const void * | instance () const noexcept |
| | Returns the instance or the context linked to a delegate, if any.
|
| |
| Ret | operator() (Args... args) const |
| | The delegate invokes the underlying function and returns the result.
|
| |
| GAIA_NODISCARD | operator bool () const noexcept |
| | Checks whether a delegate actually points to something.
|
| |
| GAIA_NODISCARD bool | operator== (const delegate< Ret(Args...)> &other) const noexcept |
| | Compares the contents of two delegates.
|
| |
| GAIA_NODISCARD bool | operator!= (const delegate< Ret(Args...)> &other) const noexcept |
| | Compares the contents of two delegates.
|
| |
template<typename Ret, typename... Args>
class gaia::util::delegate< Ret(Args...)>
Delegate for function pointers and members. It can be used as a general-purpose invoker for any free function with no memory overhead.
- Warning
- The delegate isn't responsible for the connected object or its context. User is in charge of disconnecting instances before deleting them and guarantee the lifetime of the instance is longer than that of the delegate.
- Template Parameters
-
| Ret | Return type of a function type. |
| Args | Types of arguments of a function type. |
template<typename Ret , typename... Args>
template<auto FuncToBind, typename Type >
Binds a free function with context or a bound member to a delegate. When used to bind a ree function with context, its signature must be such that the instance is the first argument before the ones used to define the delegate itself.
- Template Parameters
-
| FuncToBind | Function or member to bind to the delegate. |
| Type | Type of class or type of context. |
- Parameters
-
| value_or_instance* | A valid* reference that fits the purpose. |