diff --git a/include/stdexec/__detail/__sequence.hpp b/include/stdexec/__detail/__sequence.hpp index 45bd74698..a57918aed 100644 --- a/include/stdexec/__detail/__sequence.hpp +++ b/include/stdexec/__detail/__sequence.hpp @@ -73,12 +73,14 @@ namespace STDEXEC template struct __attrs<_Sender> { - template , class _Query, class... _Args> - requires __queryable_with<_Env2, _Query, _Args...> + using _env_t = env_of_t<_Sender>; + + template + requires __queryable_with<_env_t, _Query, _Args...> STDEXEC_ATTRIBUTE(nodiscard, always_inline, host, device) - constexpr auto operator()(_Query, _Args &&...__args) const - noexcept(__nothrow_queryable_with<_Env2, _Query, _Args...>) - -> __query_result_t<_Env2, _Query, _Args...> + constexpr auto query(_Query, _Args &&...__args) const + noexcept(__nothrow_queryable_with<_env_t, _Query, _Args...>) + -> __query_result_t<_env_t, _Query, _Args...> { return STDEXEC::get_env(__sndr_).query(_Query(), static_cast<_Args &&>(__args)...); } diff --git a/test/stdexec/algos/adaptors/test_sequence.cpp b/test/stdexec/algos/adaptors/test_sequence.cpp index ca8ad5fc8..d869b3b82 100644 --- a/test/stdexec/algos/adaptors/test_sequence.cpp +++ b/test/stdexec/algos/adaptors/test_sequence.cpp @@ -18,6 +18,7 @@ #include #include +#include #include #include @@ -187,3 +188,44 @@ TEST_CASE("sequence with sender with only first sender with throwing connect", " CHECK_THROWS(ex::connect(std::move(sndr), empty_recv::recv0{})); } #endif // !STDEXEC_NO_STD_EXCEPTIONS() + +TEST_CASE("completion domain of a sequence of one sender", "[sequence]") +{ + exec::static_thread_pool pool{1}; + + unsigned short int value = 0; + + auto sndr = exec::sequence(STDEXEC::schedule(pool.get_scheduler()) + | STDEXEC::then([&]() noexcept { value = 42; })); + + static_assert( + std::same_as< + STDEXEC::__completion_domain_of_t>, + experimental::execution::_pool_::_static_thread_pool::domain>); + + STDEXEC::sync_wait(std::move(sndr)); + + CHECK(value == 42); +} + +TEST_CASE("completion domain of a sequence of two senders", "[sequence]") +{ + exec::static_thread_pool pool{1}; + + unsigned short int value_A = 0, value_B = 0; + + auto sndr = exec::sequence(STDEXEC::schedule(pool.get_scheduler()) + | STDEXEC::then([&]() noexcept { value_A = 42; }), + STDEXEC::schedule(pool.get_scheduler()) + | STDEXEC::then([&]() noexcept { value_B = 42; })); + + static_assert( + std::same_as< + STDEXEC::__completion_domain_of_t>, + experimental::execution::_pool_::_static_thread_pool::domain>); + + STDEXEC::sync_wait(std::move(sndr)); + + CHECK(value_A == 42); + CHECK(value_B == 42); +}