Fix recursive ctor in minifunction

This commit is contained in:
alk 2023-01-18 23:05:37 +03:00 committed by GitHub
parent c35ba2e6c5
commit db109bfdf2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -31,6 +31,11 @@ namespace geode::utils {
return new MiniFunctionState(*this);
}
};
template <class Callable, class Ret, class... Args>
concept MiniFunctionCallable = requires(Callable&& func, Args... args) {
{ func(args...) } -> std::same_as<Ret>;
};
template <class Ret, class... Args>
class MiniFunction<Ret(Args...)> {
@ -56,9 +61,7 @@ namespace geode::utils {
}
template <class Callable>
requires requires(Callable&& func, Args... args) {
{ func(args...) } -> std::same_as<Ret>;
}
requires(MiniFunctionCallable<Callable, Ret, Args...> && !std::is_same_v<Callable, MiniFunction<Ret, Args...>>)
MiniFunction(Callable&& func) :
m_state(new MiniFunctionState<std::decay_t<Callable>, Ret, Args...>(std::forward<Callable>(func))) {}
@ -83,4 +86,4 @@ namespace geode::utils {
return m_state;
}
};
}
}