Skip to content

Commit b73f140

Browse files
Forward rooted environment in start_detached (#2162)
* Forward rooted environment in start_detached --------- Co-authored-by: Eric Niebler <eniebler@nvidia.com>
1 parent c928472 commit b73f140

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

include/exec/start_detached.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,10 @@ namespace experimental::execution
251251
{
252252
auto __env2 = STDEXEC::__as_root_env(static_cast<_Env&&>(__env));
253253
using __domain_t = __compl_domain_t<_Sender, STDEXEC::__as_root_env_t<_Env>>;
254-
STDEXEC::apply_sender(__domain_t{}, *this, static_cast<_Sender&&>(__sndr), __env2);
254+
STDEXEC::apply_sender(__domain_t{},
255+
*this,
256+
static_cast<_Sender&&>(__sndr),
257+
static_cast<decltype(__env2)&&>(__env2));
255258
}
256259

257260
// Below is the default implementation for `start_detached`.

test/exec/test_start_detached.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,18 @@ namespace
293293
struct env
294294
{};
295295

296+
struct move_only_env
297+
{
298+
move_only_env() = default;
299+
move_only_env(move_only_env&&) noexcept = default;
300+
move_only_env(move_only_env const &) = delete;
301+
};
302+
303+
TEST_CASE("start_detached works with a move-only environment", "[consumers][start_detached]")
304+
{
305+
exec::start_detached(ex::just(), move_only_env{});
306+
}
307+
296308
TEST_CASE("ex::on can be passed to start_detached with env", "[adaptors][ex::on]")
297309
{
298310
ex::run_loop loop;

0 commit comments

Comments
 (0)