So my question is: why does the standard allow me to have a class without a destructor if I distribute it across free storage?
Because this is not how standard functions work.
The syntax = delete you are talking about was invented to solve a number of problems. One of them was very specific: creating types that were moved or fixed, for which the compiler generated a compile-time error if you tried to call a copy (or move) constructor / assignment statement.
But the syntax has other purposes when applied as a whole. Using the =delete function, you can prevent people from invoking certain function overloads, mainly to stop certain types of problematic implicit conversions. If you do not call a function with a specific type, you get a compile-time error for calling overload delete d. Therefore, =delete allowed to apply to any function.
And the class destructor qualifies as "any function."
The purpose of this function was not to create types that would be indestructible. This is simply the result of permission =delete on any function. It is not a design or an intention; it's simple.
While using =delete for the destructor is not so much, it is also not so important to use the specification to explicitly prohibit its use on the destructor. And, of course, thereβs not much point in using =delete to behave differently when applied to the destructor.
source share