Optimizing class layout by minimizing padding safely
I have the following type and my goal is to optimize the size of Storage: struct Inlined { int data[9]; }; // sizeof => 36 struct Allocated { int* data; size_t capacity }; // sizeof => 16 union Data { Inlined inlined; Allocated allocated; }; // sizeof => 40 struct Storage { // sizeof =>… Read More Optimizing class layout by minimizing padding safely