Before modern C++ the only way to align variables or structures on a given byte boundary was to inject padding; to align a struct to 16 bytes you had to do this:
1 2 3 4 5 |
struct Old { int x; char padding[16 - sizeof(int)]; }; |
Not any more! Modern C++ introduced a keyword just for that: alignas (read more about it here). Now you can specify struct’s […]