Blender
V3.3
|
#include <BLI_function_ref.hh>
Public Types | |
using | OptionalReturnValue = std::conditional_t< std::is_void_v< Ret >, void, std::optional< Ret > > |
Public Member Functions | |
FunctionRef ()=default | |
FunctionRef (std::nullptr_t) | |
template<typename Callable , BLI_ENABLE_IF(( !std::is_same_v< std::remove_cv_t< std::remove_reference_t< Callable >>, FunctionRef >)) > | |
FunctionRef (Callable &&callable) | |
Ret | operator() (Params... params) const |
OptionalReturnValue | call_safe (Params... params) const |
operator bool () const | |
Definition at line 75 of file BLI_function_ref.hh.
using blender::FunctionRef< Ret(Params...)>::OptionalReturnValue = std::conditional_t<std::is_void_v<Ret>, void, std::optional<Ret> > |
Definition at line 135 of file BLI_function_ref.hh.
|
default |
|
inline |
Definition at line 101 of file BLI_function_ref.hh.
|
inline |
A FunctionRef
itself is a callable as well. However, we don't want that this constructor is called when Callable
is a FunctionRef
. If we would allow this, it would be easy to accidentally create a FunctionRef
that internally calls another FunctionRef
. Usually, when assigning a FunctionRef
to another, we want that both contain a reference to the same underlying callable afterwards.
It is still possible to reference another FunctionRef
by first wrapping it in another lambda.
Definition at line 118 of file BLI_function_ref.hh.
|
inline |
Calls the referenced function if it is available. The return value is of type std::optional<Ret>
if Ret
is not void
. Otherwise the return type is void
.
Definition at line 142 of file BLI_function_ref.hh.
References params.
|
inline |
Returns true, when the FunctionRef
references a function currently. If this returns false, the FunctionRef
must not be called.
Definition at line 162 of file BLI_function_ref.hh.
|
inline |
Call the referenced function and forward all parameters to it.
This invokes undefined behavior if the FunctionRef
does not reference a function currently.
Definition at line 129 of file BLI_function_ref.hh.
References BLI_assert, and params.