xenium
List of all members
xenium::aligned_object< Derived, Alignment > Struct Template Reference

A small helper class for correctly aligned dynamic allocations of over-aligned types. More...

#include <aligned_object.hpp>

Detailed Description

template<typename Derived, std::size_t Alignment = 0>
struct xenium::aligned_object< Derived, Alignment >

A small helper class for correctly aligned dynamic allocations of over-aligned types.

Dynamic allocation using the standard operator new does not consider the alignment of the allocated type. To ensure that dynamic allocations are correctly aligned, classes can inherit from aligned_object. If not specified explicitly, aligned_object implicitly uses the alignment from std::alignment_of<Derived>().

Template Parameters
Derived
Alignmentthe alignment to use for dynamic allocations. If this value is 0, the alignment is derived from Derived. Defaults to 0.