Reference Counted Class

jfondren julian.fondren at gmail.com
Wed Jul 14 19:03:47 UTC 2021


On Wednesday, 14 July 2021 at 18:33:56 UTC, Tejas wrote:
> For deterministic object destruction, there's the ```scope``` 
> storage class:
>
> ```d
> scope class_instance = new class();
> scope(exit) class_instance.destroy
>
> ```

One or the other. The `scope(exit)` will still fire on scope exit 
in the case of `auto class_instance`, and the object will still 
be destructed on scope exit without any such `scope(exit)` in the 
case of `scope class_instance`.


More information about the Digitalmars-d-learn mailing list