Wednesday, August 16, 2017

C++11: Alignment

You can specify the alignment of arrays with the alignas() operator. Previously, if you allocated bytes, you could not guarantee the alignment, which caused exceptions when the bytes were used as raw memory to back larger data types. Here is an example:
alignas(double) unsigned char buffer[1024];


No comments:

Post a Comment