Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
lewissbaker opened this issue Oct 22, 2024 · 2 comments
Labels
bug Something isn't working P0 wording

Comments

@lewissbaker
Copy link
Collaborator

lewissbaker commented Oct 22, 2024

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)?

@lewissbaker lewissbaker added bug Something isn't working P0 wording labels Oct 22, 2024
@lewissbaker
Copy link
Collaborator Author

Note that there are also other queries that are defined in terms of as_const() which should be reviewed as well.

  • get_allocator
  • get_stop_token
  • get_domain
  • get_scheduler
  • get_delegation_scheduler
  • get_forward_progress_guarantee
  • get_completion_scheduler

@lewissbaker
Copy link
Collaborator Author

This needs to have an issue filed with LWG to fix the wording for these algorithms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P0 wording
Projects
None yet
Development

No branches or pull requests

1 participant