...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.
The align function can be used to align a
pointer and is provided for implementations which do not yet provide std::align
.
The aligned_alloc function can be used in
place of ::operator
new
to specify the alignment of the
memory allocated.
The aligned_allocator class template can be
used in place of std::allocator
as an alignment-aware default allocator.
The aligned_allocator_adaptor class template can be used to adapt any allocator into an alignment-aware allocator.
The aligned_delete class can be used in place
of std::default_delete
to destroy and free objects
allocated with aligned_alloc
.
The alignment_of type trait gets the alignment
of a type, and is provided for implementations without std::alignment_of
.
The is_aligned function can be used to compare the alignment value of a pointer.