Defined in header <execution> | ||
inlineconstexpr/*unspecified*/ read_env{}; | (since C++26) (customization point object) | |
Call signature | ||
execution::senderauto 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 givenquery object.
For any query objectq, the expressionread_env(q) isexpression-equivalent to/*make-sender*/(read_env, q).
The nameexecution::read_env denotes acustomization point object, which is a constfunction object of aliteralsemiregular class type. SeeCustomizationPointObject for details.
An example usage of this factory is to schedule dependent work on the receiver's scheduler, which can be obtained withread_env(get_scheduler):
std::execution::senderauto 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