Skip to content

class.copy rules for overloading as rvalue #712

Closed
@brevzin

Description

@brevzin
Contributor

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

zygoloid commented on Apr 27, 2016

@zygoloid
Member

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

jensmaurer

jensmaurer commented on Nov 21, 2016

@jensmaurer
Member

P0135 has landed.

added a commit that references this issue on Nov 21, 2016
51afdeb
added 2 commits that reference this issue on Nov 29, 2016
b5439d9
5e4bce3
self-assigned this
on Dec 2, 2016
added 2 commits that reference this issue on Dec 14, 2016
b26770b
c38f79c
added a commit that references this issue on Dec 14, 2016
32026a5
nullptr-cpp

nullptr-cpp commented on Sep 23, 2020

@nullptr-cpp

Does anyone know which proposal this change corresponds to?

tkoeppe

tkoeppe commented on Sep 23, 2020

@tkoeppe
Contributor

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

nullptr-cpp

nullptr-cpp commented on Sep 23, 2020

@nullptr-cpp

@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

tkoeppe commented on Sep 23, 2020

@tkoeppe
Contributor

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

4 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @zygoloid@tkoeppe@brevzin@jensmaurer@nullptr-cpp

      Issue actions

        class.copy rules for overloading as rvalue · Issue #712 · cplusplus/draft