On Tuesday, 24 February 2026 at 22:11:36 UTC, Julian Fondren
wrote:
On Tuesday, 24 February 2026 at 21:56:47 UTC, monkyyy wrote:
only with a pretty void* cast is accessing a tagged union
field that happens to line up 0 indirection, everyone here is
going to tell me to do the safe then and write an abstracted
getter that gets the .offsetof `age`.
Some other options: using a common struct member for the common
cases, and rotating the struct so that you have a
struct-of-arrays (SoA) instead of an array of structs. Whether
these are wins depends on what you're doing exactly. If the
variants have very different fields, SoA stops making sense
fast. But to add 10 all the ages you would have a function that
modifies an int[]
I dont wanta do soa without compiler help, it hard, Ive tried;
its in theory 8x maybe 16x when the standard code is 10000x
slower then what I write. 10x complexity doesnt seem worth it.