19template <
class R,
class... Args>
39 requires(!std::is_same_v<std::decay_t<F>,
function_ref> &&
40 std::is_invocable_r_v<R, F &&, Args...>)
42 : obj_(
const_cast<void*
>(
43 reinterpret_cast<const void*
>(std::addressof(f)))) {
44 callback_ = [](
void* obj, Args... args) -> R {
46 *
reinterpret_cast<typename std::add_pointer<F>::type
>(obj),
47 std::forward<Args>(args)...);
67 requires std::is_invocable_r_v<R, F&&, Args...>
69 obj_ =
reinterpret_cast<void*
>(std::addressof(f));
70 callback_ = [](
void* obj, Args... args) {
72 *
reinterpret_cast<typename std::add_pointer<F>::type
>(obj),
73 std::forward<Args>(args)...);
85 std::swap(obj_, rhs.obj_);
86 std::swap(callback_, rhs.callback_);
96 return callback_(obj_, std::forward<Args>(args)...);
100 void* obj_ =
nullptr;
101 R (*callback_)(
void*, Args...) =
nullptr;
107template <
typename R,
typename... Args>
108constexpr void swap(function_ref<R(Args...)>& lhs,
109 function_ref<R(Args...)>& rhs)
noexcept {
113template <
typename R,
typename... Args>
114function_ref(R (*)(Args...)) -> function_ref<R(Args...)>;
constexpr function_ref< R(Args...)> & operator=(const function_ref< R(Args...)> &rhs) noexcept=default
constexpr function_ref< R(Args...)> & operator=(F &&f) noexcept
Definition function_ref.hpp:68
R operator()(Args... args) const
Definition function_ref.hpp:95
constexpr function_ref(const function_ref< R(Args...)> &rhs) noexcept=default
constexpr function_ref(F &&f) noexcept
Definition function_ref.hpp:41
constexpr void swap(function_ref< R(Args...)> &rhs) noexcept
Definition function_ref.hpp:84
Definition function_ref.hpp:13