115 requires (!std::is_same_v<DecayedFunc, Function>) && std::is_invocable_r_v<Return, DecayedFunc&, Args...>
117 static_assert (
sizeof (DecayedFunc) <= Capacity,
"Callable size exceeds Function capacity.");
118 static_assert (
alignof (DecayedFunc) <= Alignment,
"Callable alignment exceeds Function alignment.");
119 static_assert (std::is_nothrow_move_constructible_v<DecayedFunc>,
120 "Callable must be nothrow move constructible.");
122 new (&_storage) DecayedFunc (std::forward<Func> (callable));
124 _invoker = [] (
void* storage, Args&&... args) -> Return {
125 return static_cast<Return
> ((*
static_cast<DecayedFunc*
> (storage)) (std::forward<Args> (args)...));
129 _destructor =
nullptr;
131 if constexpr (!std::is_trivially_copyable_v<DecayedFunc>)
133 _manager = [] (
void* dst,
void* src)
noexcept {
134 DecayedFunc* source =
static_cast<DecayedFunc*
> (src);
135 new (dst) DecayedFunc (std::move (*source));
136 source->~DecayedFunc ();
140 if constexpr (!std::is_trivially_destructible_v<DecayedFunc>)
142 _destructor = [] (
void* storage)
noexcept {
143 static_cast<DecayedFunc*
> (storage)->~DecayedFunc ();
149 _size = std::is_empty_v<DecayedFunc> ? 0 :
sizeof (DecayedFunc);