class.sizeof

Tim M a at b.com
Fri Nov 14 12:17:08 PST 2008


A few years too late to by why isn't all classes objects, an instance of a  
special virtual class called Class.

On Sat, 15 Nov 2008 08:55:29 +1300, Jarrett Billingsley  
<jarrett.billingsley at gmail.com> wrote:

> On Fri, Nov 14, 2008 at 2:35 PM, Sean Kelly <sean at invisibleduck.org>  
> wrote:
>> Tomas Lindquist Olsen wrote:
>>>
>>> Denis Koroskin wrote:
>>>>
>>>> I can't find a way to get a class sizeof property - it returns 4  
>>>> (32bit
>>>> pointer size) always. I tried many ways but still can't figure out  
>>>> how to do
>>>> this. Documentation says that
>>>>
>>>> ".sizeof applied to a class object returns the size of the class
>>>> reference, not the class instantiation."
>>>>
>>>> Is it possible? Any idea is much appreciated.
>>>
>>> No nice way to do it..
>>>
>>> auto sz = myclass.classinfo.init.length;
>>>
>>> problem this is not a compiletime constant,
>>>
>>> In D2 you can use __traits to get it...
>>>
>>> Kinda lame if you ask me :P
>>>
>>> how about .instancesizeof ? I doubt that's even a remotely common  
>>> variable
>>> name ...
>>
>> I added an "isizeof" proposal to the issue tracker maybe two years ago.
>>  Feel free to vote it up if you'd like.
>
> But W will say "it's already accessible through __traits."  Not to
> sound fatalistic, but do you honestly think this would be added to D1?




More information about the Digitalmars-d mailing list