How should class objects created in betterC be destroyed
ryuukk_
ryuukk.dev at gmail.com
Mon Nov 6 16:08:41 UTC 2023
Here is how adam seems to be doing it:
https://github.com/adamdruppe/webassembly/blob/731a7033174127c0a6dd4f23eabdb440adab286b/arsd-webassembly/object.d#L650-L681
Specially here:
```D
void destroy(bool initialize = true, T)(T obj) if (is(T == class))
{
(..)
else
{
// Bypass overloaded opCast
auto ptr = (() @trusted => *cast(void**) &obj)();
rt_finalize2(ptr, true, initialize);
}
}
```
and for interface:
```D
cast(Object)obj
```
But i suspect you'll have to implement the whole typeinfo
More information about the Digitalmars-d-learn
mailing list