Skip to content

Late-CH01 11.3.5 [class.copy.assgn] p2,5 Defaulted copy and move assignment should have ref-qualifier #375

@jensmaurer

Description

@jensmaurer

The defaulted copy and move assignment operator are unqualified and as such callable on an rvalue ( 12.3.1 over.match.funcs p5.1 ) however they return an lvalue reference to *this.

Proposed change:
Do tell the truth and make the compiler provided assignment operators ref-qualified:

X& X::operator=(const X&) &
X& X::operator=(X&) &
X& X::operator=(X&&) &

This defect should be applied retroactively to all revisions from C++11 on.
Alternatively the rule 12.3.1. p5.1 could be made exempt of assignment operators

Metadata

Metadata

Assignees

No one assigned

    Labels

    EWGEvolutionrejectedNo consensus for a change.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions