It seems that in C++20 something called a "prospective destructor" was introduced. In C++17 [class.dtor]:
- In a declaration of a destructor, the declarator is a function declarator (11.3.5) of the form
ptr-declarator ( parameter-declaration-clause ) noexcept-specifier(opt) attribute-specifier-seq(opt)
In C++20 this got changed to this:
- A declaration whose declarator-id has an unqualified-id that begins with a ~ declares a prospective destructor; its declarator shall be a function declarator ([dcl.fct]) of the form
ptr-declarator ( parameter-declaration-clause ) noexcept-specifier(opt) attribute-specifier-seq(opt)
So what is this "prospective destructor"? Well the standard doesn't seem to clarify, at least for me:
- At the end of the definition of a class, overload resolution is performed among the prospective destructors declared in that class with an empty argument list to select the destructor for the class, also known as the selected destructor. The program is ill-formed if overload resolution fails.
What is the reason that this new concept of a "prospective destructor" got introduced? What does it even mean? How does it change code? What does it allow to do?
I think that perhaps this is meant to be used in template metaprogramming or maybe has do to something with SFINAE, but theses are just guesses.