17template <
class R,
class...
Args>
33 requires(!std::is_same_v<std::decay_t<F>,
function_ref> &&
34 std::is_invocable_r_v<
R,
F &&,
Args...>)
37 : obj_(
const_cast<void*
>(
38 reinterpret_cast<const void*
>(std::addressof(f)))) {
39 callback_ = [](
void*
obj,
Args... args) ->
R {
41 *
reinterpret_cast<typename std::add_pointer<F>::type
>(
obj),
42 std::forward<Args>(args)...);
58 requires std::is_invocable_r_v<
R,
F&&,
Args...>
60 obj_ =
reinterpret_cast<void*
>(std::addressof(f));
61 callback_ = [](
void*
obj,
Args... args) {
63 *
reinterpret_cast<typename std::add_pointer<F>::type
>(
obj),
64 std::forward<Args>(args)...);
74 std::swap(obj_,
rhs.obj_);
75 std::swap(callback_,
rhs.callback_);
83 return callback_(obj_, std::forward<Args>(args)...);
88 R (*callback_)(
void*,
Args...) =
nullptr;
92template <
typename R,
typename... Args>
93constexpr void swap(function_ref<R(Args...)>& lhs,
94 function_ref<R(Args...)>& rhs)
noexcept {
98template <
typename R,
typename... Args>
99function_ref(R (*)(Args...)) -> function_ref<R(Args...)>;
Definition intrusive_shared_ptr.hpp:27
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:59
R operator()(Args... args) const
Definition function_ref.hpp:82
constexpr function_ref(const function_ref< R(Args...)> &rhs) noexcept=default
constexpr function_ref(F &&f) noexcept
Definition function_ref.hpp:36
constexpr void swap(function_ref< R(Args...)> &rhs) noexcept
Definition function_ref.hpp:73
Definition function_ref.hpp:13