Namespaces
Variants
Actions

std::execution::read_env

From cppreference.com
< cpp‎ | execution
 
C++
 
Execution control library
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

Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant