Allocating a class within another class during object init w/o passing in an allocator

ag0aep6g via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Dec 16 12:13:45 PST 2016


On Friday, 16 December 2016 at 18:25:42 UTC, David  Zhang wrote:
> I though all classes were aligned to sizeof(size_t) boundaries?

I don't know.

> Wouldn't it then just be
>
> align(sizeof(size_t)) byte[__traits(classInstanceSize, 
> SomeClass)] scStorage;

I guess? I really don't have much of a clue here.

Looking around a bit, I found std.traits.classInstanceAlignment 
which seems fitting.

http://dlang.org/phobos/std_traits.html#classInstanceAlignment


More information about the Digitalmars-d-learn mailing list