From 7e930c2079ec433dbd76bc79502cb5d8b8c71acc Mon Sep 17 00:00:00 2001 From: Minh Vu Date: Sat, 8 Aug 2026 17:31:48 +0200 Subject: [PATCH] Forward rooted environment in start_detached --- include/exec/start_detached.hpp | 5 ++++- test/exec/test_start_detached.cpp | 13 +++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/include/exec/start_detached.hpp b/include/exec/start_detached.hpp index e9d2e26d6..e7e4e7956 100644 --- a/include/exec/start_detached.hpp +++ b/include/exec/start_detached.hpp @@ -251,7 +251,10 @@ namespace experimental::execution { auto __env2 = STDEXEC::__as_root_env(static_cast<_Env&&>(__env)); using __domain_t = __compl_domain_t<_Sender, STDEXEC::__as_root_env_t<_Env>>; - STDEXEC::apply_sender(__domain_t{}, *this, static_cast<_Sender&&>(__sndr), __env2); + STDEXEC::apply_sender(__domain_t{}, + *this, + static_cast<_Sender&&>(__sndr), + static_cast(__env2)); } // Below is the default implementation for `start_detached`. diff --git a/test/exec/test_start_detached.cpp b/test/exec/test_start_detached.cpp index 5ef6108d9..4ba350e1b 100644 --- a/test/exec/test_start_detached.cpp +++ b/test/exec/test_start_detached.cpp @@ -293,6 +293,19 @@ namespace struct env {}; + struct move_only_env + { + move_only_env() = default; + move_only_env(move_only_env&&) noexcept = default; + move_only_env(move_only_env const &) = delete; + }; + + TEST_CASE("start_detached works with a move-only environment", + "[consumers][start_detached]") + { + exec::start_detached(ex::just(), move_only_env{}); + } + TEST_CASE("ex::on can be passed to start_detached with env", "[adaptors][ex::on]") { ex::run_loop loop;