From ecb228603455fd588d18e56bbe07fbaefadfa3fd Mon Sep 17 00:00:00 2001 From: Cra3z Date: Fri, 21 Aug 2026 16:37:53 +0800 Subject: [PATCH] Fix concept `sender_in` --- .../beman/execution/detail/basic_sender.hpp | 11 ++++---- .../beman/execution/detail/is_constant.hpp | 7 +++-- include/beman/execution/detail/read_env.hpp | 2 ++ tests/beman/execution/exec-read-env.test.cpp | 27 +++++++++++++++++++ tests/beman/execution/exec-snd-expos.test.cpp | 2 +- 5 files changed, 40 insertions(+), 9 deletions(-) diff --git a/include/beman/execution/detail/basic_sender.hpp b/include/beman/execution/detail/basic_sender.hpp index 9fe8d449..081f2357 100644 --- a/include/beman/execution/detail/basic_sender.hpp +++ b/include/beman/execution/detail/basic_sender.hpp @@ -113,12 +113,11 @@ struct basic_sender : ::beman::execution::detail::product_type Self, typename... Env> - requires(sizeof...(Env) == 1) || (... && !::beman::execution::dependent_sender) - static consteval auto get_completion_signatures() { - if constexpr (requires { Tag::template get_completion_signatures(); }) - return Tag::template get_completion_signatures(); - else - return ::beman::execution::detail::completion_signatures_for{}; + requires((sizeof...(Env) == 1) || (... && !::beman::execution::dependent_sender)) && + requires { Tag::template get_completion_signatures(); } + static consteval auto + get_completion_signatures() noexcept(noexcept(Tag::template get_completion_signatures())) { + return Tag::template get_completion_signatures(); } template <::beman::execution::detail::decays_to Self> diff --git a/include/beman/execution/detail/is_constant.hpp b/include/beman/execution/detail/is_constant.hpp index 1dad781f..8125fdc5 100644 --- a/include/beman/execution/detail/is_constant.hpp +++ b/include/beman/execution/detail/is_constant.hpp @@ -8,8 +8,11 @@ namespace beman::execution::detail { template -concept is_constant = true; -} +auto verify_constexpr() noexcept -> void {} + +template +concept is_constant = requires { beman::execution::detail::verify_constexpr(); }; +} // namespace beman::execution::detail // ---------------------------------------------------------------------------- diff --git a/include/beman/execution/detail/read_env.hpp b/include/beman/execution/detail/read_env.hpp index 74e658c4..02419372 100644 --- a/include/beman/execution/detail/read_env.hpp +++ b/include/beman/execution/detail/read_env.hpp @@ -53,6 +53,7 @@ struct read_env_t { template struct get_signatures; template + requires std::invocable struct get_signatures<::beman::execution::detail::basic_sender<::beman::execution::detail::read_env_t, Query>, Env> { using set_value_type = ::beman::execution::set_value_t( @@ -65,6 +66,7 @@ struct read_env_t { public: template + requires requires { typename get_signatures<::std::remove_cvref_t, Env>::type; } static consteval auto get_completion_signatures() { return typename get_signatures<::std::remove_cvref_t, Env>::type{}; } diff --git a/tests/beman/execution/exec-read-env.test.cpp b/tests/beman/execution/exec-read-env.test.cpp index 9c769f92..2655adbb 100644 --- a/tests/beman/execution/exec-read-env.test.cpp +++ b/tests/beman/execution/exec-read-env.test.cpp @@ -14,13 +14,17 @@ import beman.execution.detail.join_env; #else #include #include +#include #include +#include #include #include #include #include #include #include +#include +#include #include #include #include @@ -67,6 +71,28 @@ struct receiver { auto get_env() const noexcept -> env { return {this->value}; } }; +struct env1 { + static auto query(test_std::get_allocator_t) noexcept { return std::allocator{}; } +}; + +struct env2 { + static auto query(test_std::get_scheduler_t) noexcept { return test_std::inline_scheduler{}; } +}; + +auto test_read_env_concept() -> void { + static_assert(test_std::dependent_sender); + static_assert(test_std::dependent_sender); + static_assert(test_std::sender_in); + + static_assert(not test_std::sender_in); + static_assert(test_std::sender_in); + static_assert(not test_std::sender_in); + + static_assert(not test_std::sender_in); + static_assert(not test_std::sender_in); + static_assert(test_std::sender_in); +} + auto test_read_env() -> void { static_assert(test_std::receiver); ASSERT(domain{} == test_std::get_domain(env{17})); @@ -149,6 +175,7 @@ auto test_read_env_check_types() -> void { TEST(exec_read_env) { static_assert(std::same_as); + test_read_env_concept(); test_read_env(); test_read_env_completions(); test_read_env_check_types(); diff --git a/tests/beman/execution/exec-snd-expos.test.cpp b/tests/beman/execution/exec-snd-expos.test.cpp index b91d0848..b9407f8c 100644 --- a/tests/beman/execution/exec-snd-expos.test.cpp +++ b/tests/beman/execution/exec-snd-expos.test.cpp @@ -1099,7 +1099,7 @@ auto test_completion_signatures_for() -> void { struct bad_env {}; static_assert(test_std::sender_in>); static_assert(test_std::sender_in); - //-dk:TODO restore test static_assert(not test_std::sender_in); + static_assert(not test_std::sender_in); #if 0 //-dk:TODO restore completion_signatures_for tests or remove completion_signatures for