Boost C++ Libraries

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

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext

Rationale

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, allocators, allocator adaptors, and deleters, that are alignment aware.

Table 2.2. Boost.Align solutions

Problem

Solution

::operator new(std::size_t, const std::no_throw_t&)

aligned_alloc(std::size_t, std::size_t)

::operator delete(void*)

aligned_free(void*)

std::allocator<T>

aligned_allocator<T>

Allocator

aligned_allocator_adaptor<Allocator>

std::default_delete<T>

aligned_delete


Alignment functions

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.

Alignment traits

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.

Alignment hints

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.

Alignment testing

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.


PrevUpHomeNext