75 template<
typename Ret,
typename... Params>
class FunctionRef<Ret(Params...)> {
93 template<
typename Callable>
static Ret callback_fn(
intptr_t callable, Params...
params)
95 return (*
reinterpret_cast<Callable *
>(callable))(std::forward<Params>(
params)...);
115 template<
typename Callable,
117 !std::is_same_v<std::remove_cv_t<std::remove_reference_t<Callable>>,
FunctionRef>))>
119 : callback_(callback_fn<typename
std::remove_reference_t<Callable>>),
120 callable_(reinterpret_cast<
intptr_t>(&callable))
132 return callback_(callable_, std::forward<Params>(
params)...);
144 if constexpr (std::is_void_v<Ret>) {
145 if (callback_ ==
nullptr) {
148 callback_(callable_, std::forward<Params>(
params)...);
151 if (callback_ ==
nullptr) {
154 return callback_(callable_, std::forward<Params>(
params)...);
166 return callback_ !=
nullptr;
#define BLI_ENABLE_IF(condition)
FunctionRef(Callable &&callable)
FunctionRef(std::nullptr_t)
std::conditional_t< std::is_void_v< Ret >, void, std::optional< Ret > > OptionalReturnValue
OptionalReturnValue call_safe(Params... params) const
Ret operator()(Params... params) const
SyclQueue void void size_t num_bytes void