Are D classes always garbage collected?

Froglegs lugtug at gmail.com
Wed Dec 21 22:20:18 PST 2011


>> Which returned me a nice fat null pointer.. wth? Perhaps that 
>> should be a compile time error if you aren't supposed to use 
>> classes..
>
> Strange... I'm not sure what the deal is with that overload. I 
> meant the last one on the page (that takes a void[]).


Hum I've tried the array version but I believe it contains a 
rather serious bug...

T emplace(T, Args...)(void[] chunk, Args args) if (is(T == class))
{
    enforce(chunk.length >= __traits(classInstanceSize, T),
           new ConvException("emplace: chunk size too small"));
...

This fails whenever the size is greater or equal to the amount of 
memory required :(


Anyway I need the pointer version for what I was hoping to do, 
unless there is some way to convert a pointer into an array?

Is there any way to do something like this..

void* pData = some_c_function();
void [] fakeArray = pData, size;




More information about the Digitalmars-d-learn mailing list