Class instance memory overhead lower than 3 words?

Ali Çehreli acehreli at yahoo.com
Thu Jan 25 01:50:35 UTC 2018


On 01/24/2018 05:43 PM, Jonathan M Davis wrote:
> On Thursday, January 25, 2018 00:10:32 Nicholas Wilson via Digitalmars-d-
> learn wrote:
>> One pointer for the vtbl, one for the monitor, not sure what the
>> other one is.
> 
> The TypeInfo maybe? I'm not sure where that lives.
> 
> - Jonathan M Davis
> 

Nested classes have that third pointer:


class A {
}
static assert(__traits(classInstanceSize, A) == 2 * (void*).sizeof);

void main() {
     class B {
     }
     static assert(__traits(classInstanceSize, B) == 3 * (void*).sizeof);
}

Are there other cases?

Ali


More information about the Digitalmars-d-learn mailing list