Initialize class at given location
tzsz
writing.segfaults at gmail.com
Fri Nov 28 18:14:15 UTC 2025
Hello,
I'd like to ask if there is any way of creating a class instance
at a location given by a pointer.
In C++ this is usually done using new(pointer) MyClass(); and I
saw a post made by Walter Bright that suggested adding this to D.
The code from that post did not compile on my machine tho. And
the post was a few years old, so I don't know what the current
state regarding this feature is. I really tried finding something
via Google but I was unsuccessful.
The reason for this is that I am looking for a way to use classes
with all their nice features but without the GC. Therefore I'd be
doing all the (de)allocations on my own. For this, I am currently
using malloc and free from core.stdc.
Kind regards
More information about the Digitalmars-d-learn
mailing list