Class instance alignment

kinke noone at nowhere.com
Sat Feb 20 05:44:33 UTC 2021


On Friday, 19 February 2021 at 23:53:55 UTC, tsbockman wrote:
> How can I get the alignment of a class instance? I know how to 
> get the size:
>     __traits(classInstanceSize, T)
> But, there doesn't appear to be any equivalent trait for the 
> alignment.

There's 
https://github.com/dlang/druntime/blob/728f1d9c3b7a37eba4d59ee2637fb924053cba6d/src/core/internal/traits.d#L261. But AFAIK, the GC only guarantees an alignment of 16 and doesn't respect any overaligned members or alignment spec for the class.


More information about the Digitalmars-d-learn mailing list