std::execution::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.
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
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/cpp/execution/read_env