Skip to content

Commit a1b120c

Browse files
committed
stoppable_token can handle std::stop_token being incomplete
1 parent 835c6a4 commit a1b120c

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

include/stdexec/__detail/__stop_token.hpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,28 @@ namespace stdexec {
4646
using stop_callback_for_t = __stop_callback_for<_Token, _Callback>::__t;
4747

4848
template <class _Token>
49-
concept stoppable_token =
49+
concept __stoppable_token =
5050
__nothrow_copy_constructible<_Token> && __nothrow_move_constructible<_Token>
5151
&& equality_comparable<_Token> && requires(const _Token& __token) {
5252
{ __token.stop_requested() } noexcept -> __boolean_testable_;
5353
{ __token.stop_possible() } noexcept -> __boolean_testable_;
5454
}
5555
// workaround ICE in appleclang 13.1
5656
#if !defined(__clang__)
57-
&& (__same_as<_Token, std::stop_token> || requires {
57+
&& requires {
5858
typename __stok::__check_type_alias_exists<_Token::template callback_type>;
59-
})
59+
}
6060
#endif
6161
;
6262

63+
template <class _Token>
64+
concept __stoppable_token_or = __same_as<_Token, std::stop_token> || __stoppable_token<_Token>;
65+
66+
// The cast to bool below is to make __stoppable_token_or<_Token> an atomic constraint,
67+
// hiding the disjunction within it for the sake of better compile-time performance.
68+
template <class _Token>
69+
concept stoppable_token = bool(__stoppable_token_or<_Token>);
70+
6371
template <class _Token, typename _Callback, typename _Initializer = _Callback>
6472
concept stoppable_token_for =
6573
stoppable_token<_Token> && __callable<_Callback>

0 commit comments

Comments
 (0)