Skip to content

Commit 2200f73

Browse files
committed
default implementation of __sexpr::get_env only forwards the forwarding queries
1 parent bdcb264 commit 2200f73

3 files changed

Lines changed: 21 additions & 8 deletions

File tree

include/stdexec/__detail/__basic_sender.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ namespace stdexec {
100100
inline constexpr auto __get_attrs = //
101101
[](__ignore, const auto&... __child) noexcept -> decltype(auto) {
102102
if constexpr (sizeof...(__child) == 1) {
103-
return stdexec::get_env(__child...); // BUGBUG: should be only the forwarding queries
103+
return __env::__fwd_fn()(stdexec::get_env(__child...));
104104
} else {
105105
return empty_env();
106106
}

test/stdexec/algos/adaptors/test_then.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,15 +134,15 @@ namespace {
134134

135135
TEST_CASE("then forwards env", "[adaptors][then]") {
136136
SECTION("returns env by value") {
137-
auto snd = just_with_env<value_env, int>{value_env{100}, {0}} | ex::then([](int) { });
138-
static_assert(std::same_as<decltype(ex::get_env(snd)), value_env>);
139-
CHECK(ex::get_env(snd).value == 100);
137+
auto snd = just_with_env<value_env, int>{.env_ = value_env{100}, .values_ = {0}}
138+
| ex::then([](int) { });
139+
CHECK(value_query(ex::get_env(snd)) == 100);
140140
}
141141

142142
SECTION("returns env by reference") {
143-
auto snd = just_with_env<const value_env&, int>{value_env{100}, {0}} | ex::then([](int) { });
144-
static_assert(std::same_as<decltype(ex::get_env(snd)), const value_env&>);
145-
CHECK(ex::get_env(snd).value == 100);
143+
auto snd = just_with_env<const value_env&, int>{.env_ = value_env{100}, .values_ = {0}}
144+
| ex::then([](int) { });
145+
CHECK(value_query(ex::get_env(snd)) == 100);
146146
}
147147
}
148148

test/test_common/senders.hpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,21 @@ namespace {
7373
template <class... Values>
7474
fallible_just(Values...) -> fallible_just<Values...>;
7575

76+
inline constexpr struct value_query_t : ex::forwarding_query_t {
77+
template <class Env>
78+
[[nodiscard]]
79+
auto operator()(Env const & env) const noexcept -> decltype(env.query(*this)) {
80+
return env.query(*this);
81+
}
82+
} value_query;
83+
7684
struct value_env {
77-
int value;
85+
int value{};
86+
87+
[[nodiscard]]
88+
auto query(value_query_t) const noexcept -> int {
89+
return value;
90+
}
7891
};
7992

8093
template <class Env, class... Values>

0 commit comments

Comments
 (0)