Writing system programs might require the use of data that is aligned in memory in order to access the hardware efficiently (and in some cases, to access it at all). For example, on a 32-bit architecture machine, we have the memory allocated aligned to a 4-byte boundary. In this recipe, you'll learn how to use the C++11 std::aligned_storage to allocate aligned memory. Of course, there are other, more traditional, mechanisms to allocate aligned memory, but the goal of this book is to use C++ standard library tools as much as possible.
Allocating aligned memory
How to do it...
In this section, we'll write a program that will use the allocated memory with std:...