Get class size of object
JS
js.mdnq at gmail.com
Sun Aug 11 14:05:07 PDT 2013
On Sunday, 11 August 2013 at 20:03:27 UTC, Adam D. Ruppe wrote:
> On Sunday, 11 August 2013 at 19:58:26 UTC, Adam D. Ruppe wrote:
>> Oh, I see it now. I think typeid(interface) gives a different
>> set of info.
>
> Thinking about it a bit more, this makes sense because an
> interface is not necessarily an Object - it might also be a C++
> class, or a COM object, or maybe even a slice into another vtbl
> if an Object implements multiple interfaces (not completely
> sure about the latter, I'd have to read some source, but it
> seems logical to me).
Possibly. Since I program to interfaces, every reference I use is
referenced to an interface. Needing the correct object size for
implementing an allocator was not working as "expected"(at least
as one would expect with classes). I could not see anything in
the docs that would suggest otherwise(else the light bulb might
have went off).
i.e., one would expect, IMO, that tsize would work on interfaces
because interfaces do not have a "size" so it should return the
class size of the object. (so things work uniformly and we can
program to interfaces without having to create workarounds).
More information about the Digitalmars-d-learn
mailing list