Size of a class instance at compile time

Daniel Keep daniel.keep+lists at gmail.com
Sun Jan 14 19:23:22 PST 2007


Frits van Bommel wrote:
> Daniel Keep wrote:
>> I just knocked up a slightly more robust version that should 
>> *theoretically* still work even if the members are moved around.  It 
>> basically just does the same thing yours does, but it runs over the 
>> whole tuple, and passes out the largest value it finds.
> 
> 
> Ah, that's a good solution to that problem I guess.
> Unless there's ever any weird need to put overhead bytes at the end that 
> should work.
> (Where are interface vtable pointers put? [tests] Damn, looks like 
> they're at the end :( )
> 
>> Obviously, it doesn't help for the above two points, but Walter seems 
>> to like stuff at the start of the block, not trailing off the end.  
>> Plus, when would a class require padding?
> 
> 
> Apparently, implementing an interface counts as well...

Oh... BUGGER.  Well, that's inconvenient.  I guess I'm just going to 
have to keep trying until I either find a way to do this properly, or 
Walter adds isizeof :P

Interface vtable pointers; they're just regular D arrays, right?  One 
for each interface?

Here it is: expression.html#IsExpression -- we can use is(T I == super) 
to get a tuple of the base classes and all the interfaces.  If we can 
accurately predict how large the extra padding is from the number of 
interfaces, it's sorted.

Time to go test the theory, then :)

	-- Daniel


More information about the Digitalmars-d-learn mailing list