Andrei Alexandrescu wrote:

>> Also, what about classes which don't have a default constructor?
>
> All classes have a state where all members are default initialized.

Should that state deserve a default destructor?

> I'm not adding anything. I am removing a mistake that C++ made (i.e.
> conflating destruction with deallocation)

That makes perfect sense to me. One thing that is troubling is the fact that the destructor runs twice. Is that not important?

Could double destructor call be avoided if the object received a 'default destructor' upon clear(), which is not what the programmer wrote? The reason is, the programmer's destructor has already been executed when clear() is called anyway. If the system puts the object into the .init state, shouldn't it also decide what 'default destructor' could safely be run? Perhaps empty for a class consisting merely of fundamental types...

Also, how about un-branding the object upon clear()? Would that solve the double destructor call?

Ali

Reply via email to