74template<
typename Ret,
typename... Params>
class FunctionRef<Ret(Params...)> {
79 Ret (*callback_)(intptr_t callable, Params...
params) =
nullptr;
92 template<
typename Callable>
static Ret callback_fn(intptr_t callable, Params...
params)
94 return (*
reinterpret_cast<Callable *
>(callable))(std::forward<Params>(
params)...);
112 template<
typename Callable,
114 !std::is_same_v<std::remove_cv_t<std::remove_reference_t<Callable>>,
FunctionRef>)),
115 BLI_ENABLE_IF((std::is_invocable_r_v<Ret, Callable, Params...>))>
117 : callback_(callback_fn<typename std::remove_reference_t<Callable>>),
118 callable_(intptr_t(&callable))
120 if constexpr (std::is_constructible_v<bool, Callable>) {
123#if COMPILER_CLANG || COMPILER_GCC
124# pragma GCC diagnostic push
125# pragma GCC diagnostic ignored "-Waddress"
127# pragma GCC diagnostic ignored "-Wnonnull-compare"
132 const bool is_truthy = bool(callable);
137#if COMPILER_CLANG || COMPILER_GCC
138# pragma GCC diagnostic pop
151 return callback_(callable_, std::forward<Params>(
params)...);
158 operator bool()
const
162 return callback_ !=
nullptr;