Blaze 3.9
Classes | Public Types | List of all members
blaze::AlignedAllocator< T > Class Template Reference

Allocator for type-specific aligned memory. More...

#include <AlignedAllocator.h>

Classes

struct  rebind
 Implementation of the AlignedAllocator rebind mechanism. More...
 

Public Types

using ValueType = T
 Type of the allocated values.
 
using SizeType = size_t
 Size type of the aligned allocator.
 
using DifferenceType = ptrdiff_t
 Difference type of the aligned allocator.
 
using value_type = ValueType
 Type of the allocated values.
 
using size_type = SizeType
 Size type of the aligned allocator.
 
using difference_type = DifferenceType
 Difference type of the aligned allocator.
 

Public Member Functions

Constructors
 AlignedAllocator ()=default
 
template<typename U >
 AlignedAllocator (const AlignedAllocator< U > &)
 Conversion constructor from different AlignedAllocator instances. More...
 
Allocation functions
T * allocate (size_t numObjects)
 Allocates aligned memory for the specified number of objects. More...
 
void deallocate (T *ptr, size_t numObjects) noexcept
 Deallocation of memory. More...
 

Detailed Description

template<typename T>
class blaze::AlignedAllocator< T >

Allocator for type-specific aligned memory.

The AlignedAllocator class template represents an implementation of the allocator concept of the standard library for the allocation of type-specific, aligned, uninitialized memory. The allocator performs its allocation via the blaze::alignedAllocate() and blaze::alignedDeallocate() functions to guarantee properly aligned memory based on the alignment restrictions of the specified type T. For instance, in case the given type is a fundamental, built-in data type and in case SSE vectorization is possible, the returned memory is guaranteed to be at least 16-byte aligned. In case AVX is active, the memory is even guaranteed to be at least 32-byte aligned.

Constructor & Destructor Documentation

◆ AlignedAllocator()

template<typename T >
template<typename U >
blaze::AlignedAllocator< T >::AlignedAllocator ( const AlignedAllocator< U > &  allocator)
inline

Conversion constructor from different AlignedAllocator instances.

Parameters
allocatorThe foreign aligned allocator to be copied.

Member Function Documentation

◆ allocate()

template<typename T >
T * blaze::AlignedAllocator< T >::allocate ( size_t  numObjects)
inline

Allocates aligned memory for the specified number of objects.

Parameters
numObjectsThe number of objects to be allocated.
Returns
Pointer to the newly allocated memory.

This function allocates a junk of memory for the specified number of objects of type T. The returned pointer is guaranteed to be aligned according to the alignment restrictions of the data type T. For instance, in case the type is a fundamental, built-in data type and in case SSE vectorization is possible, the returned memory is guaranteed to be at least 16-byte aligned. In case AVX is active, the memory is even guaranteed to be 32-byte aligned.

◆ deallocate()

template<typename T >
void blaze::AlignedAllocator< T >::deallocate ( T *  ptr,
size_t  numObjects 
)
inlinenoexcept

Deallocation of memory.

Parameters
ptrThe address of the first element of the array to be deallocated.
numObjectsThe number of objects to be deallocated.
Returns
void

This function deallocates a junk of memory that was previously allocated via the allocate() function. Note that the argument numObjects must be equal ot the first argument of the call to allocate() that origianlly produced ptr.


The documentation for this class was generated from the following file: