Clang is still unhappy, trying another approach with defining my own concept
This commit is contained in:
parent
4122b64ecd
commit
716f1f967a
10
src/utils.hh
10
src/utils.hh
|
@ -162,6 +162,9 @@ auto to_underlying(E value)
|
||||||
|
|
||||||
template<typename> class FunctionRef;
|
template<typename> class FunctionRef;
|
||||||
|
|
||||||
|
template<typename From, typename To>
|
||||||
|
concept ConvertibleTo = std::is_convertible_v<From, To>;
|
||||||
|
|
||||||
template<typename Res, typename... Args>
|
template<typename Res, typename... Args>
|
||||||
class FunctionRef<Res(Args...)>
|
class FunctionRef<Res(Args...)>
|
||||||
{
|
{
|
||||||
|
@ -174,9 +177,10 @@ public:
|
||||||
{}
|
{}
|
||||||
|
|
||||||
template<typename Target>
|
template<typename Target>
|
||||||
requires (not std::is_same_v<FunctionRef, std::remove_cvref_t<Target>> and
|
requires requires (Target t, Args... a) {
|
||||||
(std::is_void_v<Res> or
|
requires not std::is_same_v<FunctionRef, std::remove_cvref_t<Target>>;
|
||||||
requires (Target t, Args... a, void(&func)(Res)) { func(t(a...)); }))
|
{ t(a...) } -> ConvertibleTo<Res>;
|
||||||
|
}
|
||||||
FunctionRef(Target&& target)
|
FunctionRef(Target&& target)
|
||||||
: m_target{&target},
|
: m_target{&target},
|
||||||
m_invoker{[](void* target, Args... args) {
|
m_invoker{[](void* target, Args... args) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user