Thread overview
get size of class instance (not reference)?
Feb 26, 2013
Nick Sabalausky
Feb 26, 2013
bearophile
Feb 26, 2013
Nick Sabalausky
February 26, 2013
These just give me the size of a *reference* to the class:

class Foo {...}
Foo.sizeof
typeid(Foo).tsize

How can I get the size of a non-subclassed *instance*?

February 26, 2013
Nick Sabalausky:

> How can I get the size of a non-subclassed *instance*?

Is this enough?

http://dlang.org/traits.html#classInstanceSize

Bye,
bearophile
February 26, 2013
On Tue, 26 Feb 2013 01:54:44 +0100
"bearophile" <bearophileHUGS@lycos.com> wrote:

> Nick Sabalausky:
> 
> > How can I get the size of a non-subclassed *instance*?
> 
> Is this enough?
> 
> http://dlang.org/traits.html#classInstanceSize
> 

Ahh, yes, of course. I had a feeling I was overlooking something obvious. Thanks.

February 26, 2013
On Mon, 25 Feb 2013 20:09:05 -0500, Nick Sabalausky <SeeWebsiteToContactMe@semitwist.com> wrote:

> On Tue, 26 Feb 2013 01:54:44 +0100
> "bearophile" <bearophileHUGS@lycos.com> wrote:
>
>> Nick Sabalausky:
>>
>> > How can I get the size of a non-subclassed *instance*?
>>
>> Is this enough?
>>
>> http://dlang.org/traits.html#classInstanceSize
>>
>
> Ahh, yes, of course. I had a feeling I was overlooking something
> obvious. Thanks.

ClassInfo also has an init property which is a block of memory that is the default data in the class.  This is what druntime uses when allocating a class.

This would work to get the derived type length as well.

-Steve