51template <
class R,
class...
Args>
65 std::is_invocable_r<R, F&&,
Args...>::value>* =
nullptr>
67 : obj_(
const_cast<void*
>(
reinterpret_cast<const void*
>(std::addressof(f))))
69 callback_ = [](
void* obj,
Args... args) -> R {
71 *
reinterpret_cast<typename std::add_pointer<F>::type
>(obj),
72 std::forward<Args>(args)...);
81 template <
typename F, std::enable_if_t<std::is_invocable_r<R, F&&,
Args...>::value>* =
nullptr>
84 obj_ =
reinterpret_cast<void*
>(std::addressof(f));
85 callback_ = [](
void* obj,
Args... args) {
87 *
reinterpret_cast<typename std::add_pointer<F>::type
>(obj),
88 std::forward<Args>(args)...);
102 R
operator()(
Args... args)
const {
return callback_(obj_, std::forward<Args>(args)...); }
105 explicit operator bool() const noexcept {
return callback_ !=
nullptr; }
108 void* obj_ =
nullptr;
109 R (*callback_)(
void*,
Args...) =
nullptr;
113template <
typename R,
typename...
Args>
120template <
typename R,
typename...
Args>
constexpr function_ref(F &&f) noexcept
Constructs a function_ref referring to f.
Definition: function_ref.h:66
constexpr void swap(function_ref< R(Args...)> &rhs) noexcept
Swaps the referred callables of *this and rhs.
Definition: function_ref.h:95
constexpr function_ref< R(Args...)> & operator=(F &&f) noexcept
Makes *this refer to f.
Definition: function_ref.h:82
constexpr function_ref(const function_ref< R(Args...)> &rhs) noexcept=default
Creates a function_ref which refers to the same callable as rhs.
R operator()(Args... args) const
Call the stored callable with the given arguments.
Definition: function_ref.h:102
constexpr function_ref< R(Args...)> & operator=(const function_ref< R(Args...)> &rhs) noexcept=default
Makes *this refer to the same callable as rhs.
A lightweight non-owning reference to a callable.
Definition: function_ref.h:47
constexpr void swap(function_ref< R(Args...)> &lhs, function_ref< R(Args...)> &rhs) noexcept
Swaps the referred callables of lhs and rhs.
Definition: function_ref.h:114
function_ref(R(*)(Args...)) -> function_ref< R(Args...)>
Deduce function_ref type from a function pointer.
Main namespace for Lagrange.
Definition: AABBIGL.h:30
Definition: project.cpp:27