File tree Expand file tree Collapse file tree 5 files changed +52
-2
lines changed
include/beman/execution/detail Expand file tree Collapse file tree 5 files changed +52
-2
lines changed Original file line number Diff line number Diff line change 44#ifndef INCLUDED_BEMAN_EXECUTION_DETAIL_STOP_CALLBACK_FOR
55#define INCLUDED_BEMAN_EXECUTION_DETAIL_STOP_CALLBACK_FOR
66
7+ #include < beman/execution/detail/stop_token_traits.hpp>
78#include < concepts>
89
910// ----------------------------------------------------------------------------
1011
1112namespace beman ::execution {
1213template <class Token , class CallbackFun >
13- using stop_callback_for_t = typename Token::template callback_type<CallbackFun>;
14+ using stop_callback_for_t =
15+ typename ::beman::execution::detail::stoppable_token_traits<Token>::template callback_type<CallbackFun>;
1416}
1517
1618namespace beman ::execution::detail {
Original file line number Diff line number Diff line change 1+ // include/beman/execution/detail/stop_token_traits.hpp -*-C++-*-
2+ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3+
4+ #ifndef INCLUDED_BEMAN_EXECUTION_DETAIL_STOP_TOKEN_TRAITS
5+ #define INCLUDED_BEMAN_EXECUTION_DETAIL_STOP_TOKEN_TRAITS
6+
7+ #include < beman/execution/detail/check_type_alias_exist.hpp>
8+ #include < stop_token>
9+
10+ // ----------------------------------------------------------------------------
11+
12+ namespace beman ::execution::detail {
13+ template <typename >
14+ struct stoppable_token_traits ;
15+
16+ template <typename Token>
17+ requires requires { typename check_type_alias_exist<Token::template callback_type>; }
18+ struct stoppable_token_traits <Token> {
19+ template <typename Fn>
20+ using callback_type = typename Token::template callback_type<Fn>;
21+ };
22+
23+ template <>
24+ struct stoppable_token_traits <std::stop_token> {
25+ template <typename Fn>
26+ using callback_type = std::stop_callback<Fn>;
27+ };
28+ } // namespace beman::execution::detail
29+
30+ // ----------------------------------------------------------------------------
31+
32+ #endif
Original file line number Diff line number Diff line change 55#define INCLUDED_BEMAN_EXECUTION_DETAIL_STOPPABLE_TOKEN
66
77#include < beman/execution/detail/check_type_alias_exist.hpp>
8+ #include < beman/execution/detail/stop_token_traits.hpp>
89#include < concepts>
910
1011// ----------------------------------------------------------------------------
1112
1213namespace beman ::execution {
1314template <typename Token>
1415concept stoppable_token = requires (const Token& token) {
15- typename ::beman::execution::detail::check_type_alias_exist<Token::template callback_type>;
16+ typename ::beman::execution::detail::check_type_alias_exist<
17+ ::beman::execution::detail::stoppable_token_traits<Token>::template callback_type>;
1618 { token.stop_requested () } noexcept -> ::std::same_as<bool >;
1719 { token.stop_possible () } noexcept -> ::std::same_as<bool >;
1820 { Token (token) } noexcept ;
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ endif()
2121list (
2222 APPEND execution_tests
2323 exec-affine-on .test
24+ issue-200.test
2425 issue-174.test
2526 issue-186.test
2627 exec-scope-counting.test
Original file line number Diff line number Diff line change 1+ // tests/beman/execution/issue-200.test.cpp -*-C++-*-
2+ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3+
4+ #include < beman/execution/detail/stoppable_token.hpp>
5+ #include < test/execution.hpp>
6+ #include < stop_token>
7+
8+ // ----------------------------------------------------------------------------
9+
10+ auto main () -> int {
11+ static_assert (test_std::stoppable_token<std::stop_token>);
12+ return 0 ;
13+ }
You can’t perform that action at this time.
0 commit comments