Class instance memory overhead lower than 3 words?
Jonathan M Davis
newsgroup.d at jmdavisprog.com
Thu Jan 25 02:11:06 UTC 2018
On Wednesday, January 24, 2018 17:50:35 Ali Çehreli via Digitalmars-d-learn
wrote:
> 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?
Well, a class nested inside another class would, but that's just another
type of nested class. If it's not nested, it won't have a pointer to any
kind of outer scope though.
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list