Sizeof class instance
grauzone
none at example.net
Sun Oct 4 00:47:24 PDT 2009
Justin Johansson wrote:
> How does one determine the sizeof (in bytes) of an instance of a class in D?
>
> .sizeof works as advertised for structs, but for reference types,
> .sizeof yields the sizeof the referencing variable (effectively same as size of a pointer)
> and not the size of the underlying instance.
As Jarrett said, x.classinfo.init.length is the simplest way in D1.
> I did try scanning the NG and read spec_D1.00.pdf. Perhaps I missed it in the latter.
I guess that PDF is horribly outdated, although it may work for some
purposes.
> btw. I was poking under the hood of std.xml and though, wow, instances of Element
> class look humongous, and so I'm interested to how exactly how humongous.
Wasn't std.xml for D2? Anyway, last what I remember is that std.xml is
unmaintained, slow, buggy, and shouldn't be seriously used.
> Thanks for all help.
> Justin
>
More information about the Digitalmars-d-learn
mailing list