Enumerated Unions (sum types)
Paul Backus
snarwin at gmail.com
Thu Sep 12 12:07:06 UTC 2024
On Thursday, 12 September 2024 at 11:19:07 UTC, Dukc wrote:
> But to know the size of the sum type, the existence, size and
> alignment of the tag field has to be known. That's why I'd
> prefer it to be specified.
Also, the tag field itself will be visible to reflection (via
`__traits(allMembers)`, which includes hidden fields), and will
have its own `.sizeof`, `.alignof`, and `.offsetof` properties.
So you can get this information if you really want it.
"Unspecified" just means that the compiler is free to choose
whatever layout it wants for the tag field, and is not required
to document its choice, so the programmer should not make any
assumptions about it.
More information about the dip.ideas
mailing list