On Thursday, 15 December 2016 at 21:37:34 UTC, David  Zhang wrote:
So the size of Foo would be the size of SomeClass plus members? ie. Is the size of the array stored too?

With these definitions:

----
class SomeClass {}

class Foo
{
    this()
    {
        import std.conv: emplace;
        emplace!SomeClass(scStorage);
    }

@property SomeClass sc() { return cast(SomeClass) scStorage.ptr; }
    void[__traits(classInstanceSize, SomeClass)] scStorage;
}
----

the "instance size" of Foo is the size of

a) Foo's hidden/implicit fields which all classes have, plus
b) the size of scStorage which is Foo's only explicit field.

The size of scStorage is the instance size of SomeClass (just the implicit fields here). The size/length of scStorage is known at compile-time. It's not stored in Foo.

Reply via email to