From 5387743d91f25cb6e847152650f19e00ec75f04b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dietmar=20K=C3=BChl?= Date: Sun, 25 Jan 2026 00:17:04 +0000 Subject: [PATCH 1/3] address issue 200: use stop_callback_traits to support std::stop_token --- .../execution/detail/stop_callback_for_t.hpp | 4 ++- .../execution/detail/stop_token_traits.hpp | 32 +++++++++++++++++++ .../execution/detail/stoppable_token.hpp | 4 ++- tests/beman/execution/CMakeLists.txt | 1 + tests/beman/execution/issue-200.test.cpp | 13 ++++++++ 5 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 include/beman/execution/detail/stop_token_traits.hpp create mode 100644 tests/beman/execution/issue-200.test.cpp 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..72557196 --- /dev/null +++ b/include/beman/execution/detail/stop_token_traits.hpp @@ -0,0 +1,32 @@ +// 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; +}; + +template <> +struct stoppable_token_traits { + template + using callback_type = std::stop_callback; +}; +} // 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..1469edca --- /dev/null +++ b/tests/beman/execution/issue-200.test.cpp @@ -0,0 +1,13 @@ +// tests/beman/execution/issue-200.test.cpp -*-C++-*- +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include +#include +#include + +// ---------------------------------------------------------------------------- + +auto main() -> int { + static_assert(test_std::stoppable_token); + return 0; +} \ No newline at end of file From 8dc804b4b5c4def8f2d7387dc8d6acf3f36ae282 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dietmar=20K=C3=BChl?= Date: Sun, 25 Jan 2026 00:41:39 +0000 Subject: [PATCH 2/3] avoid issue with libc++ not defining stop_token --- include/beman/execution/detail/stop_token_traits.hpp | 2 ++ tests/beman/execution/issue-200.test.cpp | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/beman/execution/detail/stop_token_traits.hpp b/include/beman/execution/detail/stop_token_traits.hpp index 72557196..14db9f2c 100644 --- a/include/beman/execution/detail/stop_token_traits.hpp +++ b/include/beman/execution/detail/stop_token_traits.hpp @@ -20,11 +20,13 @@ struct stoppable_token_traits { using callback_type = typename Token::template callback_type; }; +#if not defined(__clang__) || __clang_major__ > 19 template <> struct stoppable_token_traits { template using callback_type = std::stop_callback; }; +#endif } // namespace beman::execution::detail // ---------------------------------------------------------------------------- diff --git a/tests/beman/execution/issue-200.test.cpp b/tests/beman/execution/issue-200.test.cpp index 1469edca..e7ac0108 100644 --- a/tests/beman/execution/issue-200.test.cpp +++ b/tests/beman/execution/issue-200.test.cpp @@ -8,6 +8,8 @@ // ---------------------------------------------------------------------------- auto main() -> int { +#if not defined(__clang__) || __clang_major__ > 19 static_assert(test_std::stoppable_token); +#endif return 0; -} \ No newline at end of file +} From 18c3e570abbadad313f466a5f4f8703f8368e80b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dietmar=20K=C3=BChl?= Date: Sun, 25 Jan 2026 00:50:35 +0000 Subject: [PATCH 3/3] followed copilot suggestion on using ::std:: consistently --- include/beman/execution/detail/stop_token_traits.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/beman/execution/detail/stop_token_traits.hpp b/include/beman/execution/detail/stop_token_traits.hpp index 14db9f2c..43c72812 100644 --- a/include/beman/execution/detail/stop_token_traits.hpp +++ b/include/beman/execution/detail/stop_token_traits.hpp @@ -22,9 +22,9 @@ struct stoppable_token_traits { #if not defined(__clang__) || __clang_major__ > 19 template <> -struct stoppable_token_traits { +struct stoppable_token_traits<::std::stop_token> { template - using callback_type = std::stop_callback; + using callback_type = ::std::stop_callback; }; #endif } // namespace beman::execution::detail