diff options
| author | Maxime Coste <mawww@kakoune.org> | 2021-11-25 22:30:02 +1100 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2021-11-25 22:32:10 +1100 |
| commit | 716f1f967a2d2fc22390b05d23c62c444f68ebff (patch) | |
| tree | 6d98ad83435c218dd247f5081405249f80ec53d9 /src | |
| parent | 4122b64ecd25648ffd792a8733a633343197fbee (diff) | |
Clang is still unhappy, trying another approach with defining my own concept
Diffstat (limited to 'src')
| -rw-r--r-- | src/utils.hh | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/utils.hh b/src/utils.hh index 21ed5fd3..7b7fd2d7 100644 --- a/src/utils.hh +++ b/src/utils.hh @@ -162,6 +162,9 @@ auto to_underlying(E value) template<typename> class FunctionRef; +template<typename From, typename To> +concept ConvertibleTo = std::is_convertible_v<From, To>; + template<typename Res, typename... Args> class FunctionRef<Res(Args...)> { @@ -174,9 +177,10 @@ public: {} template<typename Target> - requires (not std::is_same_v<FunctionRef, std::remove_cvref_t<Target>> and - (std::is_void_v<Res> or - requires (Target t, Args... a, void(&func)(Res)) { func(t(a...)); })) + requires requires (Target t, Args... a) { + requires not std::is_same_v<FunctionRef, std::remove_cvref_t<Target>>; + { t(a...) } -> ConvertibleTo<Res>; + } FunctionRef(Target&& target) : m_target{&target}, m_invoker{[](void* target, Args... args) { |
