struct destructor

Adam D. Ruppe destructionator at gmail.com
Sat May 15 18:24:36 UTC 2021


On Saturday, 15 May 2021 at 18:15:24 UTC, Dennis wrote:
> On Saturday, 15 May 2021 at 17:55:17 UTC, Alain De Vos wrote:
>> Feature request, a function old which does the opposite of 
>> new, allowing deterministic,real-time behavior and memory 
>> conservation.
>
> You can use 
> [object.destroy](https://dlang.org/phobos/object.html#.destroy) 
> to destruct, and 
> [GC.free](https://dlang.org/phobos/core_memory.html#.GC.free) 
> to free memory allocated with `new`.

Specifically you wanna do:

```
.destroy(*ptr);
GC.free(GC.addrOf(ptr));
```


More information about the Digitalmars-d-learn mailing list