Comment by mgaunard
2 hours ago
You can also just do that in C++. I do that as part of my messaging usually, so that the objects are trivially relocatable and reinterpret-castable. It only works so long as you combine a set of canonical types, but that can be verified or converted using C++26 reflection.
I have both what I call inline sequences, and out-of-line ones (store an offset to the object itself rather than pointers).
I made all my sizes and offset 32-bit, but I suppose they could have been 16-bit.
This is also the default C behavior.