This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 116a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2024-12-19


1586. Naming a destructor via decltype

Section: 11.4.7  [class.dtor]     Status: NAD     Submitter: Steve Clamage     Date: 2012-11-14

Use of a decltype-specifier to name a destructor in an explicit destructor call is explicitly permitted in 11.4.7 [class.dtor] paragraph 13. However, the most straightforward attempt to do so, e.g.,

  p->~decltype(*p)()

does not work, because *p is an lvalue and thus decltype(*p) is a reference type, not a class type. Even simply eliminating the reference is not sufficient, because p could be a pointer to a cv-qualified class type.

Either the provision for decltype-specifiers in explicit destructor calls should be removed or the specification should be expanded to allow reference and cv-qualified types to be considered as “denot[ing] the destructor's class type.”

Notes from the April, 2013 meeting:

CWG favored replacing the existing syntax with something more flexible, for example, p->~auto(). This new syntax would also apply to pseudo destructors.

Rationale (November, 2013):

CWG felt that the suggested change should be considered by EWG before the issue is resolved.

Additional note, April, 2015:

EWG has decided not to make a change in this area. See EWG issue 112.