diff --git a/include/stdexec/__detail/__stop_token.hpp b/include/stdexec/__detail/__stop_token.hpp index 55b27a9cf..3b58ae0cd 100644 --- a/include/stdexec/__detail/__stop_token.hpp +++ b/include/stdexec/__detail/__stop_token.hpp @@ -160,12 +160,10 @@ STDEXEC_P2300_NAMESPACE_BEGIN() STDEXEC_MODULE_EXPORT template - concept unstoppable_token = - stoppable_token<_Token> // - && requires { - { _Token::stop_possible() } -> STDEXEC::__boolean_testable_; - } // - && (!_Token::stop_possible()); + concept unstoppable_token = stoppable_token<_Token> && requires { + { _Token::stop_possible() } -> STDEXEC::__boolean_testable_; + requires STDEXEC::__mbool<(!_Token::stop_possible())>::value; + }; template struct __stoppable_base_for<_Token> diff --git a/test/stdexec/concepts/test_concepts_stop_tokens.cpp b/test/stdexec/concepts/test_concepts_stop_tokens.cpp index c3baf2cb9..a5e9a5125 100644 --- a/test/stdexec/concepts/test_concepts_stop_tokens.cpp +++ b/test/stdexec/concepts/test_concepts_stop_tokens.cpp @@ -76,6 +76,45 @@ namespace #endif } + struct runtime_stop_possible_token + { + template + struct callback_type + { + template + explicit callback_type(runtime_stop_possible_token const &, Init&&) noexcept + {} + }; + + static auto stop_possible() noexcept -> bool + { + return false; + } + + auto stop_requested() const noexcept -> bool + { + return false; + } + + auto operator==(runtime_stop_possible_token const &) const noexcept -> bool = default; + }; + + struct constexpr_stop_possible_token : runtime_stop_possible_token + { + static constexpr auto stop_possible() noexcept -> bool + { + return true; + } + }; + + TEST_CASE("unstoppable_token requires a constant-false static stop_possible", "[concepts]") + { + STATIC_REQUIRE(::STDEXEC::stoppable_token); + STATIC_REQUIRE(!::STDEXEC::unstoppable_token); + STATIC_REQUIRE(::STDEXEC::stoppable_token); + STATIC_REQUIRE(!::STDEXEC::unstoppable_token); + } + TEST_CASE("inplace_stop_callback supports class template argument deduction", "[stop_token]") { ::STDEXEC::inplace_stop_source source;