Idomatic way to guarantee to run destructor?
Ali Çehreli
acehreli at yahoo.com
Mon May 4 09:20:06 UTC 2020
On 4/30/20 10:04 AM, Ben Jones wrote:> On Thursday, 30 April 2020 at
16:55:36 UTC, Robert M. Münch wrote:
> I think you want to use scope rather than auto which will put the class
> on the stack and call its destructor:
> https://dlang.org/spec/attribute.html#scope
That is correct about calling the destructor but the object would still
be allocated with 'new', hence be on the heap. There is also library
feature 'scoped', which places the object on the stack:
https://dlang.org/phobos/std_typecons.html#scoped
Ali
More information about the Digitalmars-d-learn
mailing list