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

CPOs inhibit guaranteed copy elision of arguments, are unimplementable as specified #4264

Closed
ericniebler opened this issue Oct 1, 2020 · 3 comments
Labels
lwg Issue must be reviewed by LWG.

Comments

@ericniebler
Copy link

To take one example, [range.access.begin]/p2.5

Otherwise, if [...] then ranges::begin(E) is expression-equivalent to decay-copy(begin(t))

Expression-equivalent is defined in [defns.expression-equivalent]:

expressions that all have the same effects, either are all potentially-throwing (14.5) or are all not
potentially throwing, and either are all constant subexpressions or are all not constant subexpressions.

[Example: For a value x of type int and a function f that accepts integer arguments, the expressions
f(x +2), f(2 + x), and f(1 + x + 1) are expression-equivalent. —end example]

But according to https://en.cppreference.com/w/cpp/language/copy_elision, only PRvalues are subject to guaranteed copy elision. So it is possible that in decay-copy(begin(t)), the elision of the copy of t is required, but for ranges::begin(E) copy elision may happen, but it is not required.

Therefore, they are not expression-equivalent expressions, as that term of power is currently specified.

@ericniebler
Copy link
Author

attn @CaseyCarter

@jensmaurer
Copy link
Member

This is the issue tracker for editorial issues around the C++ standard. I'm not seeing anything we could fix as an editorial issue here (i.e.without changing the meaning of the standard). Defects in the definition of "expression-equivalent" should be directed to LWG, it seems.

@ericniebler
Copy link
Author

So sorry.

@jensmaurer jensmaurer added after-motions Pull request is to be applied after the pending edits from WG21 straw polls have been applied. lwg Issue must be reviewed by LWG. and removed after-motions Pull request is to be applied after the pending edits from WG21 straw polls have been applied. labels Oct 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lwg Issue must be reviewed by LWG.
Projects
None yet
Development

No branches or pull requests

2 participants