Skip to content

get_env() specified in terms of as_const() but this doesn't work with rvalue senders #296

Open
@lewissbaker

Description

@lewissbaker

The current specification of std::execution::get_env() defines get_env(o) as as_const(o).get_env().

However, the as_const() function has a deleted rvalue-taking overload, meaning that you cannot pass temporaries to it.

This means that several uses of get_env() which pass expressions with are either potentially rvalues (e.g. in definition of connect(sndr, rcvr) it uses the expression get_env(rcvr), but rcvr could be, and usually is, a prvalue) or always rvalues (e.g. scheduler concept has the expression get_env(schedule(std::forward<Sch>(sch)))).

The intent here was that get_env() is a function that takes as an argument a const T& and thus allows prvalues to bind to it. We basically just want to require that get_env() finds a const-qualified member-function. The use of as_const() does not seem to mirror the semantics of a function with a const T& parameter, so I suggest we change it to something else.

Maybe an exposition-only AS-CONST(expr) that is equivalent to []<class T>(const T& x) noexcept -> const T& { return x; }(expr)?

Metadata

Metadata

Assignees

No one assigned

    Labels

    P0bugSomething isn't workingpending-wg21A paper or an LWG issue exitswording

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions