What should happen here?
Paul Backus
snarwin at gmail.com
Sun Sep 26 13:33:05 UTC 2021
On Sunday, 26 September 2021 at 13:29:26 UTC, Paul Backus wrote:
> On Sunday, 26 September 2021 at 07:49:46 UTC, Daniel N wrote:
>> // I hope this works, otherwise it violates the 'law of least
>> surprise'
>> auto c = new Class()
>> scope(exit) destroy(c);
>>
>> If scope(exit) also works, then I don't think there is any
>> problem...
>
> Destroy on a class reference doesn't call the destructor; it
> just sets the reference to null.
Correction: I remembered wrong; it actually does call the
destructor. So this will work for classes with non-trivial
destructors.
More information about the Digitalmars-d
mailing list