|
cds
2.3.2
|
Aligned allocator. More...
#include <cds/os/alloc_aligned.h>
Data Structures | |
| struct | rebind |
| convert an aligned_allocator<T> to an aligned_allocator<OTHER> More... | |
Public Types | |
| typedef prototype::value_type | value_type |
| value type | |
| typedef prototype::pointer | pointer |
| pointer to value type | |
| typedef prototype::reference | reference |
| value reference type | |
| typedef prototype::const_pointer | const_pointer |
| const pointer to value type | |
| typedef prototype::const_reference | const_reference |
| const value reference type | |
| typedef prototype::size_type | size_type |
| size type | |
| typedef prototype::difference_type | difference_type |
| difference type | |
Public Member Functions | |
| pointer | address (reference v) const |
return address of mutable v | |
| const_pointer | address (const_reference v) const |
return address of nonmutable v | |
| aligned_allocator (const aligned_allocator< T > &) noexcept | |
| construct by copying (do nothing) | |
| template<class OTHER > | |
| aligned_allocator (const aligned_allocator< OTHER > &) noexcept | |
| construct from a related allocator (do nothing) | |
| template<class OTHER > | |
| aligned_allocator< T > & | operator= (const aligned_allocator< OTHER > &) |
| assign from a related allocator (do nothing) | |
| void | deallocate (pointer ptr, size_type) |
deallocate object at ptr, ignore size | |
| pointer | allocate (size_type nAlign, size_type nCount) |
allocate array of nCount elements More... | |
| pointer | allocate (size_type nAlign, size_type nCount, const void *) |
allocate array of nCount elements, ignore hint More... | |
| void | construct (pointer ptr, const T &val) |
construct object at ptr with value val | |
| void | destroy (pointer ptr) |
destroy object at ptr | |
| size_type | max_size () const noexcept |
| estimate maximum array size | |
Private Types | |
| typedef std::allocator< T > | prototype |
| prototype (the source of typedefs) | |
Aligned allocator.
This allocator is intended for allocating of an aligned memory block. It uses wrappers around platform-specific function for allocating and deallocating the block of memory:
aligned_malloc for allocating aligned_free for deallocatingThe aligned_malloc function wraps:
for Win: _aligned_malloc function for other OSes: posix_memalign / memalign functionThe aligned_free function wraps:
for Win: _aligned_free function for other OSes: free functionThis class should not be used directly. Use cds::details::AlignedAllocator instead.
|
inline |
allocate array of nCount elements
The address returned is aligned by nAlign boundary. nAlign parameter should be power of 2.
The function guarantees the alignment for first element of array only. To guarantee the alignment for each element of the array the size of an object of type T must be multiple of nAlign:
The function, like operator new does not return nullptr. In no memory situation the function throws std::bad_alloc exception.
|
inline |
allocate array of nCount elements, ignore hint
The address returned is aligned by nAlign boundary. nAlign parameter should be power of 2.
The function guarantees alignment for first element of array only.