On Sunday, 24 January 2021 at 11:00:17 UTC, vitamin wrote:

void destruct(Base base){
void[] x = (cast(void*)base)[0 .. __traits(classInstanceSize, Base)];
    writeln("deallocate: ", x.length);
    theAllocator.deallocate(x);
}

You can get the dynamic size of an object using `typeid(base).initializer.length`.

Base base = new Derived;
assert(__traits(classInstanceSize, Derived) == typeid(base).initializer.length);

--
/Jacob Carlborg


Reply via email to