mirror of
https://github.com/momo5502/emulator.git
synced 2026-01-22 05:03:56 +00:00
added more callbacks
This commit is contained in:
@@ -27,19 +27,13 @@ namespace utils
|
||||
{
|
||||
}
|
||||
|
||||
optional_function& operator=(std::function<Ret(Args...)> f)
|
||||
template <typename F, typename = std::enable_if_t<std::is_invocable_r_v<Ret, F, Args...>>>
|
||||
optional_function& operator=(F&& f)
|
||||
{
|
||||
func = std::move(f);
|
||||
func = std::forward<F>(f);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
requires(!std::is_same_v<std::remove_cvref_t<T>, std::function<Ret(Args...)>>)
|
||||
optional_function& operator=(T&& t)
|
||||
{
|
||||
return this->operator=(std::function<Ret(Args...)>(std::forward<T>(t)));
|
||||
}
|
||||
|
||||
Ret operator()(Args... args) const
|
||||
{
|
||||
if (func)
|
||||
|
||||
Reference in New Issue
Block a user