Title
Implicitly deleted move operation should not disable trivial relocation
Status
open
Section
11.2 [class.prop]
Submitter
Pablo Halpern

Created on 2025-07-10.00:00:00 last changed 2 weeks ago

Messages

Date: 2025-08-15.00:00:00

Additional notes (August, 2025)

Forwarded to EWG to confirm design intent with paper issue #2408, by decision of the CWG chair.

Date: 2025-08-11.21:12:02

Suggested resolution:

Change in 11.2 [class.prop] paragraph 2 as follows:

A class C is default-movable if
  • overload resolution for direct-initializing an object of type C from an xvalue of type C selects a constructor that is a direct member of C and is neither user-provided nor explicitly deleted,
  • overload resolution for assigning to an lvalue of type C from an xvalue of type C selects an assignment operator function that is a direct member of C and is neither user-provided nor explicitly deleted, and
  • C has a destructor that is neither user-provided nor explicitly deleted.
Date: 2025-08-11.21:12:51

Consider:

  struct A { const int i; };   // trivially copyable, but not trivially relocatable (deleted copy-assignment)
  struct B { int& r; };        // trivially copyable, but not trivially relocatable (deleted copy-assignment)
  struct C trivially_relocatable_if_eligible { C(); C operator=(const C&) = delete; }; // trivially relocatable
  struct D { C m; };           // not trivially relocatable

All of A, B, D ought to be trivially relocatable, but are not per the current Working Draft, because their copy assignment operators are implicitly deleted.

History
Date User Action Args
2025-08-11 21:12:02adminsetmessages: + msg8067
2025-08-11 21:12:02adminsetmessages: + msg8066
2025-07-10 00:00:00admincreate