Title
Implicit-lifetime aggregates
Status
c++23
Section
11.2 [class.prop]
Submitter
Davis Herring

Created on 2022-06-27.00:00:00 last changed 16 months ago

Messages

Date: 2022-11-09.21:36:35

Proposed resolution (approved by CWG 2022-11-09):

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

A class S is an implicit-lifetime class if
  • it is an aggregate whose destructor is not user-provided or
  • it has at least one trivial eligible constructor and a trivial, non-deleted destructor.
Date: 2022-11-09.21:36:35

CWG 2022-11-09:

A deleted destructor does not prevent an aggregate from being an implicit-lifetime class.

Date: 2022-09-15.00:00:00

Additional notes (September, 2022):

From a thread starting here: What if X had a deleted destructor (either explicitly or implicitly)?

Date: 2022-11-15.00:00:00

[Accepted as a DR at the November, 2022 meeting.]

Subclause 11.2 [class.prop] paragraph 9 specifies:

A class S is an implicit-lifetime class if
  • it is an aggregate or
  • it has at least one trivial eligible constructor and a trivial, non-deleted destructor.

However, an aggregate may have a non-deleted non-trivial destructor:

  struct X {
    Y i;
    ~X();
  };

This class is an aggregate, but destroying X itself (ignoring the subobjects) does not satisfy "destroying an instance of the type runs no code"; see P0593R6 "Implicit creation of objects for low-level object manipulation" section 3.1.

History
Date User Action Args
2023-07-16 13:00:43adminsetstatus: open -> c++23
2023-07-16 13:00:43adminsetstatus: drwp -> open
2023-02-18 18:43:04adminsetstatus: dr -> drwp
2022-11-25 05:14:04adminsetstatus: ready -> dr
2022-11-09 21:36:35adminsetstatus: tentatively ready -> ready
2022-11-09 21:36:35adminsetmessages: + msg7012
2022-11-09 21:36:35adminsetstatus: tentatively ready -> tentatively ready
2022-11-09 21:36:35adminsetstatus: tentatively ready -> tentatively ready
2022-11-09 21:36:35adminsetmessages: + msg6990
2022-11-09 21:36:35adminsetstatus: tentatively ready -> tentatively ready
2022-11-09 21:27:56adminsetstatus: ready -> tentatively ready
2022-11-09 21:27:56adminsetstatus: ready -> ready
2022-11-09 21:27:56adminsetstatus: ready -> ready
2022-09-01 14:43:59adminsetmessages: + msg6918
2022-08-19 07:54:33adminsetstatus: open -> ready
2022-06-27 00:00:00admincreate