cstdalign
struct MyStruct {
char c;
int i;
};
alignas(32) MyStruct myStruct; // Aligns MyStruct to a 32-byte boundarystruct SharedData {
int count;
std::mutex mtx;
};
__attribute__((aligned(64))) SharedData sharedData; // Aligns SharedData to a 64-byte boundary for efficient multi-threaded accessint data[16] __attribute__((aligned(16))); // Aligns the array to a 16-byte boundary for vectorization optimizationsstruct CacheLineAligned {
char pad[64]; // Adds 64 bytes of padding to align the following data to a cache line boundary
int data;
};