14 template<
typename F,
typename T>
17 template<
typename T,
typename R,
typename U,
typename... Args>
20 template<
typename T,
typename M,
typename G>
24 template<
typename T,
typename M,
typename G>
28 template<
typename F,
typename T>
31 template<
typename Function>
34 template<
typename R,
typename... Args>
38 template<
typename... Fs>
47 template<
typename R,
typename... Args>
51 template<
typename... Fs>
60 template<
typename R,
typename... Args>
64 template<
typename... Fs>
73 template<
typename R,
typename... Args>
77 template<
typename... Fs>
93 template<concepts::Object T>
96 template<concepts::Object T>
99 template<concepts::LanguageFunction T>
109 return static_cast<T*
>(storage.
pointer);
115 template<
typename Sig,
typename = meta::Type<SignatureInfo<Sig>>>
118 template<
typename Sig,
typename R,
typename... Args>
123 template<
typename... Fs>
124 constexpr static bool is_invocable = Info::template is_invocable<Fs...>;
126 constexpr static bool is_noexcept = Info::is_noexcept;
129 using CVQualified = Info::template Qualified<T>;
133 using Qualified = CVQualified<T>&;
135 using ErasedFunctionPointer = R (*)(
ErasedStorage, Args&&...)
noexcept(is_noexcept);
138 template<concepts::LanguageFunction F>
139 requires(is_invocable<F>)
147 template<
typename F,
typename T = meta::RemoveReference<F>>
149 is_invocable<Qualified<F>>)
152 : m_storage(util::addressof(
function))
153 , m_impl([](
ErasedStorage storage, Args&&... args)
noexcept(is_noexcept) -> R {
159 template<auto f,
typename F = decltype(f)>
160 requires(is_invocable<F>)
162 : m_impl([](
ErasedStorage, Args&&... args) noexcept(is_noexcept) -> R {
167 static_assert(f !=
nullptr,
"FunctionRef Constexpr<> constructors cannot be passed a nullptr.");
172 template<auto f,
typename U,
typename F = decltype(f),
typename T = meta::RemoveReference<U>>
175 : m_storage(
util::addressof(object))
176 , m_impl([](
ErasedStorage storage, Args&&... args) noexcept(is_noexcept) -> R {
178 Qualified<T> object_reference = *
down_cast<T>(storage);
183 static_assert(f !=
nullptr,
"FunctionRef Constexpr<> constructors cannot be passed a nullptr.");
188 template<auto f,
typename T,
typename F = decltype(f)>
189 requires(is_invocable<F, CVQualified<T>*>)
191 : m_storage(object), m_impl([](
ErasedStorage storage, Args&&... args) noexcept(is_noexcept) -> R {
196 static_assert(f !=
nullptr,
"FunctionRef Constexpr<> constructors cannot be passed a nullptr.");
206 constexpr auto operator()(Args... args)
const noexcept(is_noexcept) -> R {
207 return m_impl(m_storage, util::forward<Args>(args)...);
212 ErasedFunctionPointer m_impl {
nullptr };
215 template<concepts::LanguageFunction F>
218 template<auto f,
typename F = meta::RemovePo
inter<decltype(f)>>
222 template<auto f,
typename T,
typename F = decltype(f)>
#define DI_ASSERT(...)
Definition assert_bool.h:7
Definition function_ref.h:116
auto operator=(T) -> FunctionRef &=delete
constexpr FunctionRef(Constexpr< f >, U &&object)
Definition function_ref.h:174
constexpr FunctionRef(F *function)
Definition function_ref.h:140
constexpr FunctionRef(Constexpr< f >)
Definition function_ref.h:161
constexpr FunctionRef(Constexpr< f >, CVQualified< T > *object)
Definition function_ref.h:190
constexpr auto operator()(Args... args) const noexcept(is_noexcept) -> R
Definition function_ref.h:206
constexpr FunctionRef(F &&function)
Definition function_ref.h:151
Definition language.h:171
Definition language.h:370
Definition function_ref.h:13
meta::Type< SignatureAfterBindFrontHelper< F, T > > SignatureAfterBindFront
Definition function_ref.h:29
constexpr auto down_cast(ErasedStorage storage)
Definition function_ref.h:105
constexpr auto invoke_r
Definition invoke.h:103
Definition zstring_parser.h:9
Definition function_ref.h:15
Definition function_ref.h:32
R(Args...) Type
Definition function_ref.h:36
T const Qualified
Definition function_ref.h:83
static constexpr bool is_invocable
Definition function_ref.h:65
static constexpr bool is_noexcept
Definition function_ref.h:80
static constexpr bool is_invocable
Definition function_ref.h:39
static constexpr bool is_invocable
Definition function_ref.h:52
T Qualified
Definition function_ref.h:44
T const Qualified
Definition function_ref.h:57
static constexpr bool is_noexcept
Definition function_ref.h:41
R(Args...) Type
Definition function_ref.h:49
T Qualified
Definition function_ref.h:70
R(Args...) Type
Definition function_ref.h:62
R(Args...) Type
Definition function_ref.h:75
static constexpr bool is_noexcept
Definition function_ref.h:67
static constexpr bool is_noexcept
Definition function_ref.h:54
static constexpr bool is_invocable
Definition function_ref.h:78
Definition function_ref.h:86
void const * const_pointer
Definition function_ref.h:88
void * pointer
Definition function_ref.h:87
constexpr ErasedStorage(T *pointer_)
Definition function_ref.h:94
constexpr ErasedStorage()=default
constexpr ErasedStorage(T const *const_pointer_)
Definition function_ref.h:97
void(* function_pointer)()
Definition function_ref.h:89
ErasedStorage(T *function_pointer_)
Definition function_ref.h:100