get size of class instance (not reference)?
Steven Schveighoffer
schveiguy at yahoo.com
Tue Feb 26 07:35:40 PST 2013
On Mon, 25 Feb 2013 20:09:05 -0500, Nick Sabalausky
<SeeWebsiteToContactMe at semitwist.com> wrote:
> On Tue, 26 Feb 2013 01:54:44 +0100
> "bearophile" <bearophileHUGS at 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
More information about the Digitalmars-d-learn
mailing list