Thread overview | ||||||
---|---|---|---|---|---|---|
|
February 26, 2013 get size of class instance (not reference)? | ||||
---|---|---|---|---|
| ||||
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 Re: get size of class instance (not reference)? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nick Sabalausky | 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 Re: get size of class instance (not reference)? | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | 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 Re: get size of class instance (not reference)? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nick Sabalausky | 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 |
Copyright © 1999-2021 by the D Language Foundation