Blender V4.3
blender::FunctionRef< Ret(Params...)> Class Template Reference

#include <BLI_function_ref.hh>

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 >)) , BLI_ENABLE_IF((std::is_invocable_r_v< Ret, Callable, Params... >)) >
 FunctionRef (Callable &&callable)
 
Ret operator() (Params... params) const
 
 operator bool () const
 

Detailed Description

template<typename Ret, typename... Params>
class blender::FunctionRef< Ret(Params...)>

Definition at line 76 of file BLI_function_ref.hh.

Constructor & Destructor Documentation

◆ FunctionRef() [1/3]

template<typename Ret , typename... Params>
blender::FunctionRef< Ret(Params...)>::FunctionRef ( )
default

◆ FunctionRef() [2/3]

template<typename Ret , typename... Params>
blender::FunctionRef< Ret(Params...)>::FunctionRef ( std::nullptr_t )
inline

Definition at line 102 of file BLI_function_ref.hh.

◆ FunctionRef() [3/3]

template<typename Ret , typename... Params>
template<typename Callable , BLI_ENABLE_IF(( !std::is_same_v< std::remove_cv_t< std::remove_reference_t< Callable > >, FunctionRef >)) , BLI_ENABLE_IF((std::is_invocable_r_v< Ret, Callable, Params... >)) >
blender::FunctionRef< Ret(Params...)>::FunctionRef ( Callable && callable)
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.

Member Function Documentation

◆ operator bool()

template<typename Ret , typename... Params>
blender::FunctionRef< Ret(Params...)>::operator bool ( ) const
inline

Returns true, when the FunctionRef references a function currently. If this returns false, the FunctionRef must not be called.

Definition at line 139 of file BLI_function_ref.hh.

◆ operator()()

template<typename Ret , typename... Params>
Ret blender::FunctionRef< Ret(Params...)>::operator() ( Params... params) const
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.


The documentation for this class was generated from the following file: