23template <
typename T, std::
size_t Alignment>
74 const std::size_t alloc_size = n *
sizeof(T) + Alignment;
77 if (hbw_posix_memalign(&ptr, alignment, alloc_size) != 0)
78 throw std::bad_alloc();
80 if (posix_memalign(&ptr, Alignment, alloc_size) != 0)
81 throw std::bad_alloc();
83 return reinterpret_cast<T*
>(ptr);
124template <
typename T, std::
size_t Alignment>
138template <
typename T, std::
size_t Alignment>
std::vector< K, AlignedAllocator< K, ALIGN > > aligned_vector
Type alias for a std::vector with aligned memory allocation.
Definition Allocator.hpp:111
bool operator!=(const AlignedAllocator< T, Alignment > &, const AlignedAllocator< T, Alignment > &) noexcept
Inequality operator for AlignedAllocator.
Definition Allocator.hpp:139
bool operator==(const AlignedAllocator< T, Alignment > &, const AlignedAllocator< T, Alignment > &) noexcept
Equality operator for AlignedAllocator.
Definition Allocator.hpp:125
Rebinding structure for allocator traits.
Definition Allocator.hpp:42
Aligned memory allocator for high-performance computing.
Definition Allocator.hpp:24
T value_type
Definition Allocator.hpp:25
T * pointer
Definition Allocator.hpp:26
std::size_t size_type
Definition Allocator.hpp:30
std::ptrdiff_t difference_type
Definition Allocator.hpp:31
T * allocate(std::size_t n)
Allocates aligned memory for n elements of type T.
Definition Allocator.hpp:72
T & reference
Definition Allocator.hpp:28
void deallocate(T *p, std::size_t) noexcept
Deallocates memory previously allocated with allocate().
Definition Allocator.hpp:93
AlignedAllocator() noexcept=default
Conversion constructor from another allocator of different type.
const T & const_reference
Definition Allocator.hpp:29
const T * const_pointer
Definition Allocator.hpp:27