I thought I heard that D classes have two words (2 void*) of overhead instead of the one word required by C++. I also heard that the vtable layout is incompatible with C++. Do I remember correctly? If so what is the rationale for these decisions?
A few things:
Object
, so it always has that __vptr
overhead, but also has a __monitor
, which C++ class objects don't have.vptr
for each interface that the class implements.The vtable layout is incompatible with C++ because D includes a pointer to a TypeInfo
instance, which has runtime type information about the class. C++ obviously doesn't have that, so it is incompatible.