Aligned memory allocator¶
-
template<class
T, size_tAlign>
classxsimd::aligned_allocator¶ Allocator for aligned memory.
The aligned_allocator class template is an allocator that performs memory allocation aligned by the specified value.
- tparam T
type of objects to allocate.
- tparam Align
alignment in bytes.
Public Functions
-
inline
aligned_allocator() noexcept¶ Default constructor.
-
inline
aligned_allocator(const aligned_allocator &rhs) noexcept¶ Copy constructor.
-
inline
~aligned_allocator()¶ Destructor.
-
inline pointer
address(reference) noexcept¶ Returns the actual address of
reven in presence of overloadedoperator&.- Parameters
r – the object to acquire address of.
- Returns
the actual address of
r.
-
inline const_pointer
address(const_reference) const noexcept¶ Returns the actual address of
reven in presence of overloadedoperator&.- Parameters
r – the object to acquire address of.
- Returns
the actual address of
r.
-
inline pointer
allocate(size_type n, const void *hint = 0)¶ Allocates
n * sizeof(T)bytes of uninitialized memory, aligned byA.The alignment may require some extra memory allocation.
- Parameters
n – the number of objects to allocate storage for.
hint – unused parameter provided for standard compliance.
- Returns
a pointer to the first byte of a memory block suitably aligned and sufficient to hold an array of
nobjects of typeT.
-
inline void
deallocate(pointer p, size_type n)¶ Deallocates the storage referenced by the pointer p, which must be a pointer obtained by an earlier call to allocate().
The argument
nmust be equal to the first argument of the call to allocate() that originally producedp; otherwise, the behavior is undefined.- Parameters
p – pointer obtained from allocate().
n – number of objects earlier passed to allocate().
-
inline size_type
max_size() const noexcept¶ Returns the maximum theoretically possible value of
n, for which the call allocate(n, 0) could succeed.- Returns
the maximum supported allocated size.
-
inline size_type
size_max() const noexcept¶ This method is deprecated, use max_size() instead.
-
template<class
U, class ...Args>
inline voidconstruct(U *p, Args&&... args)¶ Constructs an object of type
Tin allocated uninitialized memory pointed to byp, using placement-new.- Parameters
p – pointer to allocated uninitialized memory.
args – the constructor arguments to use.
-
template<class
U>
inline voiddestroy(U *p)¶ Calls the destructor of the object pointed to by
p.- Parameters
p – pointer to the object that is going to be destroyed.
-
template<class
U>
inlinealigned_allocator(const aligned_allocator<U, A>&) noexcept¶ Extended copy constructor.
-
template<class
U>
structrebind¶
Comparison operators¶
-
template<class
T1, size_tA1, classT2, size_tA2>
inline booloperator==(const aligned_allocator<T1, A1> &lhs, const aligned_allocator<T2, A2> &rhs) noexcept¶ Compares two aligned memory allocator for equality.
Since allocators are stateless, return
trueiffA1 == A2.- Parameters
lhs – aligned_allocator to compare.
rhs – aligned_allocator to compare.
- Returns
true if the allocators have the same alignment.
-
template<class
T1, size_tA1, classT2, size_tA2>
inline booloperator!=(const aligned_allocator<T1, A1> &lhs, const aligned_allocator<T2, A2> &rhs) noexcept¶ Compares two aligned memory allocator for inequality.
Since allocators are stateless, return
trueiffA1 != A2.- Parameters
lhs – aligned_allocator to compare.
rhs – aligned_allocator to compare.
- Returns
true if the allocators have different alignments.