How should class objects created in betterC be destroyed
zoe
fionalde at outlook.com
Tue Nov 7 02:42:52 UTC 2023
On Monday, 6 November 2023 at 16:08:41 UTC, ryuukk_ wrote:
> 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
Thanks, I found out later that I couldn't use the cast keyword
More information about the Digitalmars-d-learn
mailing list