Difference between revisions of "cpp/execution/read env"
From cppreference.com
m (std:: in the signature.. But also I wonder how the signatures in exec.syn are supposed to work) |
m (_env) |
||
Line 1: | Line 1: | ||
− | {{cpp/execution/title| | + | {{cpp/execution/title|read_env}} |
{{cpp/execution/navbar}} | {{cpp/execution/navbar}} | ||
{{ddcl|since=c++26|header=execution| | {{ddcl|since=c++26|header=execution| |
Revision as of 13:16, 4 October 2024
Defined in header <execution>
|
||
std::execution::sender auto read_env( auto q ); |
(since C++26) | |
Parameters
q | - | query object for querying the receiver's environment |
This section is incomplete Reason: come up with template for CPO wording here |
For any query object q
, the expression read_env(q) is expression-equivalent to /*make-sender*/(read_env, q).
Return value
Returns a sender that reaches into a receiver’s environment and pulls out the current value associated with the query object denoted by q
.
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