On 04/03/15 17:43, Steven Schveighoffer wrote:
On 3/4/15 8:43 AM, Shachar Shemesh wrote:

I'd expect A's destructor to run, which does not seem to be the case.


I believe destructors are not run when you throw inside a constructor.
So plan to deallocate if the ctor throws:

a = A(var + 1);
scope(failure) destroy(a);

-Steve

That's pretty horrible. So now I need to keep track of the implementation of my members to figure out whether it is okay to skip the destructor or not.

All of this from a language that claims to support RAII, which was invented precisely so the programmer does not have to keep track of those things.

I think this is precisely the sort of corner cases that drive people away from C++.

Shachar

Reply via email to