Description
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.
Activity
zygoloid commentedon Apr 27, 2016
I'd prefer to not make any changes here until P0135 lands, because it's going to change this wording.
jensmaurer commentedon Nov 21, 2016
P0135 has landed.
[class.copy] Rephrase rule preferring a move constructor
[class.copy] Rephrase rule preferring a move constructor
[class.copy] Rephrase rule preferring a move constructor
[class.copy] Rephrase rule preferring a move constructor
[class.copy] Rephrase rule preferring a move constructor
[class.copy] Rephrase rule preferring a move constructor
nullptr-cpp commentedon Sep 23, 2020
Does anyone know which proposal this change corresponds to?
tkoeppe commentedon Sep 23, 2020
Could you try git-blame until you find the motion application commit?
nullptr-cpp commentedon Sep 23, 2020
@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 commentedon Sep 23, 2020
Yes yes, right, now continue git-blaming from before that commit, look where the previous content came from, etc.
4 remaining items