...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
C++11 added the ability to specify increased alignment (over-alignment) for
class types. Unfortunately, ::operator new
allocation functions, new
expressions,
and the default allocator, std::allocator
,
do not support dynamic memory allocation of over-aligned data. This library
provides allocation functions, allocators, allocator adaptors, and deleters,
that are alignment aware.
Table 2.2. Boost.Align solutions
Problem |
Solution |
---|---|
|
|
|
|
|
|
|
|
|
|
C++11 provided std::align
in the standard library to align a
pointer value. Unfortunately some C++ standard library implementations do not
support it yet (libstdc++ as far as gcc 4.8.0) and other standard library implementations
implement it incorrectly (dinkumware in msvc 11.0). This library provides it
for those implementations and also for C++03 compilers where it is equally
useful.
C++11 provided the std::alignment_of
trait in the standard library
to query the alignment requirement of a type. Unfortunately some C++ standard
library vendors do not implement it in an entirely standard conforming manner,
such as for array types (libc++ as far as clang 3.4). Other vendor implementations
report incorrect values for certain types, such as pointer to members (msvc
14.0). This library provides it for those implementations and also for C++03
compilers where it is equally useful.
Allocating aligned memory is sometimes not enough to ensure that optimal code is generated. Developers use specific compiler intrinsics to notify the compiler of a given alignment property of a memory block. This library provides a macro to abstract that functionality for compilers with the appropriate intrinsics.
This library provides a function to test the alignment of a pointer value. It is generally useful in assertions to validate that memory is correctly aligned.