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

class.copy rules for overloading as rvalue #712

Closed
brevzin opened this issue Apr 20, 2016 · 10 comments
Closed

class.copy rules for overloading as rvalue #712

brevzin opened this issue Apr 20, 2016 · 10 comments
Assignees

Comments

@brevzin
Copy link
Contributor

brevzin commented Apr 20, 2016

The rule for potentially selecting the the constructor as if the object were an rvalue currently reads as:

When the criteria for elision of a copy/move operation are met, but not for an exception-declaration, and the object to be copied is designated by an lvalue, or when the expression in a return statement is a (possibly parenthesized) id-expression that names an object with automatic storage duration declared in the body or parameter-declaration-clause of the innermost enclosing function or lambda-expression, overload resolution to select the constructor for the copy is first performed as if the object were designated by an rvalue.

This is a very long sentence with lots of internal boolean operators, and every three months I come across this sentence and mis-parse it. It would be great to come with with a rewording of this such that it's obvious what the two cases are. Something to the effect of:

Overload resolution to select the constructor for the copy is first performed as if the object were designated by an rvalue if either:

  • the criteria for elision of a copy/move operation are met, but not for an exception-declaration, and the object to be copied is designated by an lvalue, or
  • the expression in a return statement is a (possibly parenthesized) id-expression that names an object with automatic storage duration declared in the body or parameter-declaration-clause of the innermost enclosing function or lambda-expression

Or really any other kind of editorial wizardry to clearly separate the two conditions that lead to the rvalue overload being considered.

@zygoloid
Copy link
Member

I'd prefer to not make any changes here until P0135 lands, because it's going to change this wording.

@jensmaurer
Copy link
Member

P0135 has landed.

jensmaurer added a commit to jensmaurer/draft that referenced this issue Nov 21, 2016
in a throw-expression or a return statement.

Fixes cplusplus#712.
jensmaurer added a commit to jensmaurer/draft that referenced this issue Nov 29, 2016
in a throw-expression or a return statement.

Fixes cplusplus#712.
jensmaurer added a commit to jensmaurer/draft that referenced this issue Nov 30, 2016
in a throw-expression or a return statement.

Fixes cplusplus#712.
@jensmaurer jensmaurer self-assigned this Dec 2, 2016
jensmaurer added a commit to jensmaurer/draft that referenced this issue Dec 14, 2016
in a throw-expression or a return statement.

Fixes cplusplus#712.
jensmaurer added a commit to jensmaurer/draft that referenced this issue Dec 14, 2016
in a throw-expression or a return statement.

Fixes cplusplus#712.
zygoloid pushed a commit that referenced this issue Dec 14, 2016
in a throw-expression or a return statement.

Fixes #712.
@nullptr-cpp
Copy link

Does anyone know which proposal this change corresponds to?

@tkoeppe
Copy link
Contributor

tkoeppe commented Sep 23, 2020

Could you try git-blame until you find the motion application commit?

@nullptr-cpp
Copy link

@tkoeppe
32026a5

[class.copy] Rephrase rule preferring a move constructor

in a throw-expression or a return statement.

Fixes #712.

I got here through this commit :)

@tkoeppe
Copy link
Contributor

tkoeppe commented Sep 23, 2020

Yes yes, right, now continue git-blaming from before that commit, look where the previous content came from, etc.

@jensmaurer
Copy link
Member

I believe these rules are entirely misplaced in a "copy elision" section. After all, elision is optional, but moving is mandatory. I'm trying to fix this in #3998.

@nullptr-cpp
Copy link

@tkoeppe
I have done this before, and what I want to know now is which proposal this commit corresponds to?
I want to know the corresponding proposal number, I can't find it in commit history 😅

@tkoeppe
Copy link
Contributor

tkoeppe commented Sep 23, 2020

@nullptr-cpp: I don't know and would just do the same thing I advised. If you get all the way to commit 1, then this wording has been there since before C++11 and we'd need to look much harder.

@tkoeppe
Copy link
Contributor

tkoeppe commented Sep 23, 2020

@nullptr-cpp: Yes, the original wording "When the criteria for elision" was already present in the first commit on GitHub:

When the criteria for elision of a copy operation are met

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants