Reuse object memory?

Namespace via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Apr 19 14:34:20 PDT 2015


And if I have an already instantiated object?
----
Foo f = new Foo();
// reuse f's memory
----
Is there an nicer way to override the memory instead of:
----
void[] buf = (cast(void*) f)[0 .. __traits(classInstanceSize, 
Foo)];
buf = typeid(Foo).init[]; // or: buf = f.classinfo.init[];
----
?

The void* cast looks very ugly.


More information about the Digitalmars-d-learn mailing list