diff --git a/include/beman/execution/detail/stop_callback_for_t.hpp b/include/beman/execution/detail/stop_callback_for_t.hpp index 6177c49b..089c2696 100644 --- a/include/beman/execution/detail/stop_callback_for_t.hpp +++ b/include/beman/execution/detail/stop_callback_for_t.hpp @@ -4,13 +4,15 @@ #ifndef INCLUDED_BEMAN_EXECUTION_DETAIL_STOP_CALLBACK_FOR #define INCLUDED_BEMAN_EXECUTION_DETAIL_STOP_CALLBACK_FOR +#include #include // ---------------------------------------------------------------------------- namespace beman::execution { template -using stop_callback_for_t = typename Token::template callback_type; +using stop_callback_for_t = + typename ::beman::execution::detail::stoppable_token_traits::template callback_type; } namespace beman::execution::detail { diff --git a/include/beman/execution/detail/stop_token_traits.hpp b/include/beman/execution/detail/stop_token_traits.hpp new file mode 100644 index 00000000..43c72812 --- /dev/null +++ b/include/beman/execution/detail/stop_token_traits.hpp @@ -0,0 +1,34 @@ +// include/beman/execution/detail/stop_token_traits.hpp -*-C++-*- +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#ifndef INCLUDED_BEMAN_EXECUTION_DETAIL_STOP_TOKEN_TRAITS +#define INCLUDED_BEMAN_EXECUTION_DETAIL_STOP_TOKEN_TRAITS + +#include +#include + +// ---------------------------------------------------------------------------- + +namespace beman::execution::detail { +template +struct stoppable_token_traits; + +template + requires requires { typename check_type_alias_exist; } +struct stoppable_token_traits { + template + using callback_type = typename Token::template callback_type; +}; + +#if not defined(__clang__) || __clang_major__ > 19 +template <> +struct stoppable_token_traits<::std::stop_token> { + template + using callback_type = ::std::stop_callback; +}; +#endif +} // namespace beman::execution::detail + +// ---------------------------------------------------------------------------- + +#endif diff --git a/include/beman/execution/detail/stoppable_token.hpp b/include/beman/execution/detail/stoppable_token.hpp index 14aa405c..55a9ed3b 100644 --- a/include/beman/execution/detail/stoppable_token.hpp +++ b/include/beman/execution/detail/stoppable_token.hpp @@ -5,6 +5,7 @@ #define INCLUDED_BEMAN_EXECUTION_DETAIL_STOPPABLE_TOKEN #include +#include #include // ---------------------------------------------------------------------------- @@ -12,7 +13,8 @@ namespace beman::execution { template concept stoppable_token = requires(const Token& token) { - typename ::beman::execution::detail::check_type_alias_exist; + typename ::beman::execution::detail::check_type_alias_exist< + ::beman::execution::detail::stoppable_token_traits::template callback_type>; { token.stop_requested() } noexcept -> ::std::same_as; { token.stop_possible() } noexcept -> ::std::same_as; { Token(token) } noexcept; diff --git a/tests/beman/execution/CMakeLists.txt b/tests/beman/execution/CMakeLists.txt index 4f4fefc7..c39e07b6 100644 --- a/tests/beman/execution/CMakeLists.txt +++ b/tests/beman/execution/CMakeLists.txt @@ -21,6 +21,7 @@ endif() list( APPEND execution_tests exec-affine-on.test + issue-200.test issue-174.test issue-186.test exec-scope-counting.test diff --git a/tests/beman/execution/issue-200.test.cpp b/tests/beman/execution/issue-200.test.cpp new file mode 100644 index 00000000..e7ac0108 --- /dev/null +++ b/tests/beman/execution/issue-200.test.cpp @@ -0,0 +1,15 @@ +// tests/beman/execution/issue-200.test.cpp -*-C++-*- +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include +#include +#include + +// ---------------------------------------------------------------------------- + +auto main() -> int { +#if not defined(__clang__) || __clang_major__ > 19 + static_assert(test_std::stoppable_token); +#endif + return 0; +}