Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
libc++ doesn't implement any concepts yet, use variable templates instead.
- Loading branch information
Showing
1 changed file
with
5 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -554,27 +554,27 @@ class Task { | |
* returns an awaitable (Task<R>) then the result of then is the awaitable. | ||
*/ | ||
template<typename ThenCallback> | ||
requires (std::invocable<ThenCallback> || (!std::is_void_v<T> && std::invocable<ThenCallback, T>)) | ||
requires (std::is_invocable_v<ThenCallback> || (!std::is_void_v<T> && std::is_invocable_v<ThenCallback, T>)) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
danvratil
Author
Owner
|
||
auto then(ThenCallback &&callback) { | ||
return thenImpl(std::forward<ThenCallback>(callback)); | ||
} | ||
|
||
template<typename ThenCallback, typename ErrorCallback> | ||
requires ((std::invocable<ThenCallback> || (!std::is_void_v<T> && std::invocable<ThenCallback, T>)) && | ||
std::invocable<ErrorCallback, const std::exception &>) | ||
requires ((std::is_invocable_v<ThenCallback> || (!std::is_void_v<T> && std::is_invocable_v<ThenCallback, T>)) && | ||
std::is_invocable_v<ErrorCallback, const std::exception &>) | ||
auto then(ThenCallback &&callback, ErrorCallback &&errorCallback) { | ||
return thenImpl(std::forward<ThenCallback>(callback), std::forward<ErrorCallback>(errorCallback)); | ||
} | ||
|
||
private: | ||
template<typename ThenCallback, typename ... Args> | ||
requires (std::invocable<ThenCallback>) | ||
requires (std::is_invocable_v<ThenCallback>) | ||
auto invoke(ThenCallback &&callback, Args && ...) { | ||
return callback(); | ||
} | ||
|
||
template<typename ThenCallback, typename Arg> | ||
requires (std::invocable<ThenCallback, Arg>) | ||
requires (std::is_invocable_v<ThenCallback, Arg>) | ||
auto invoke(ThenCallback &&callback, Arg && arg) { | ||
return callback(std::forward<Arg>(arg)); | ||
} | ||
|
There's
concepts_p.h
in qcoro which does something similar, but forconstructible_from
. It's at least partly wrong, conflating "Clang" with Apple's released versions of libc++ (and Clang's own versions thereof). For instance, this version of Clang + libc++ will build qcoro without the patch:FreeBSD clang version 13.0.0 (git@github.com:llvm/llvm-project.git llvmorg-13.0.0-0-gd7b669b3a303)
It can also
#if 0
out the Clang part ofconcepts_p.h
without any problem. So the code is much more sensitive to variations in the standard library. Apparently FreeBSD 13.0 needs this patch as well, and FreeBSD 12.3 still has Clang 10 by default. Anyway, flat-out Clang-no-concepts isn't right, even if the code isn't wrong like this.