The code for "object.destroy" for classes looks like:
void destroy(T)(T obj) if (is(T == class))
{
static if(__traits(getLinkage, T) == "C++")
{
obj.__xdtor();
enum classSize = __traits(classInstanceSize, T);
(cast(void*)obj)[0 .. classSize] = typeid(T).initializer[];
}
else
rt_finalize(cast(void*)obj);
}
The code should check for Objective-C and potentially COM classes as well.
https://github.com/dlang/druntime/blob/14bd877bc51014baf9090175f2e690d8e1ec3a4a/src/object.d#L562
Comment #1 by robert.schadek — 2024-12-07T13:38:32Z