std::execution::read_env
From cppreference.com
C++
Feature test macros (C++20)
Concepts library (C++20)
Metaprogramming library (C++11)
Ranges library (C++20)
Filesystem library (C++17)
Concurrency support library (C++11)
Execution control library (C++26)
Execution control library
read_env
Defined in header
<execution>
inline constexpr /*unspecified*/ read_env{};
(since C++26) (customization point object)
Call signature
execution::sender auto read_env( auto&& query );
(since C++26)
A sender factory that returns a sender that reaches into a receiver’s environment and pulls out the current value associated with a given query object.
For any query object q
, the expression read_env(q) is expression-equivalent to /*make-sender*/(read_env, q).
Customization point objects
The name execution::read_env
denotes a customization point object, which is a const function object of a literal semiregular
class type. See CustomizationPointObject for details.
[edit] Example
An example usage of this factory is to schedule dependent work on the receiver's scheduler, which can be obtained with read_env(get_scheduler):
std::execution::sender auto task = std::execution::read_env(std::execution::get_scheduler) | std::execution::let_value([](auto sched) { return std::execution::starts_on(sched, /*some nested work here*/); }); std::this_thread::sync_wait( std::move(task) ); // wait for it to finish