Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards



Dynamic allocation

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 and allocators that respect the alignment requirements of a type and so are suitable for allocating memory for over-aligned types.

aligned_alloc(alignment, size)

Replaces ::operator new(size, std::nothrow)


Replaces ::operator delete(pointer, std::nothrow)


Replaces std::allocator<T>


Replaces use of Allocator


Replaces std::default_delete<T>

Pointer alignment

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 msvc11.0). This library provides it for those implementations and also for C++03 compilers where it is equally useful.

Querying alignment

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.

Hinting alignment

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, BOOST_ALIGN_ASSUME_ALIGNED, to abstract that functionality for compilers with the appropriate intrinsics.

Checking alignment

This library provides a function, is_aligned to test the alignment of a pointer value. It is generally useful in assertions to validate that memory is correctly aligned.