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...>)
43 : obj_(
const_cast<void*
>(
44 reinterpret_cast<const void*
>(std::addressof(f)))) {
45 callback_ = [](
void*
obj,
Args... args) ->
R {
47 *
reinterpret_cast<typename std::add_pointer<F>::type
>(
obj),
48 std::forward<Args>(args)...);
68 requires std::is_invocable_r_v<
R,
F&&,
Args...>
70 obj_ =
reinterpret_cast<void*
>(std::addressof(f));
71 callback_ = [](
void*
obj,
Args... args) {
73 *
reinterpret_cast<typename std::add_pointer<F>::type
>(
obj),
74 std::forward<Args>(args)...);
86 std::swap(obj_,
rhs.obj_);
87 std::swap(callback_,
rhs.callback_);
97 return callback_(obj_, std::forward<Args>(args)...);
101 void* obj_ =
nullptr;
102 R (*callback_)(
void*,
Args...) =
nullptr;
108template <
typename R,
typename... Args>
109constexpr void swap(function_ref<R(Args...)>& lhs,
110 function_ref<R(Args...)>& rhs)
noexcept {
114template <
typename R,
typename... Args>
115function_ref(R (*)(Args...)) -> function_ref<R(Args...)>;
Definition intrusive_shared_ptr.hpp:29
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:69
R operator()(Args... args) const
Definition function_ref.hpp:96
constexpr function_ref(const function_ref< R(Args...)> &rhs) noexcept=default
constexpr function_ref(F &&f) noexcept
Definition function_ref.hpp:42
constexpr void swap(function_ref< R(Args...)> &rhs) noexcept
Definition function_ref.hpp:85
Definition function_ref.hpp:13