size of a class instance

Sean Kelly sean at f4.ca
Tue Nov 14 08:42:10 PST 2006


Bill Baxter wrote:
> 
> I guess when it comes down to it, finding the size of a class is really 
> only useful for satisfying one's curiosity and optimizing member orders 
> to get better alignment.  And for that purpose I guess it doesn't really 
> have to be that intuitive a name.

But the existing method only works at run time, which doesn't allow for 
things like this:

     byte[MyClass.isizeof] buf;
     MyClass c = new(&buf[0]) MyClass();
     scope(exit) delete c;

Evil, I know, but it kind of stinks that alloca is the only means we 
currently have to construct classes on the stack.


Sean



More information about the Digitalmars-d-learn mailing list