Aligned memory allocator for STL containers.
More...
#include <AlignedAllocator.h>
|
typedef T * | pointer |
| Pointer to the allocated type.
|
|
typedef const T * | const_pointer |
| Const pointer to the allocated type.
|
|
typedef T & | reference |
| Reference to the allocated type.
|
|
typedef const T & | const_reference |
| Const reference to the allocated type.
|
|
typedef T | value_type |
| The allocated type.
|
|
typedef size_t | size_type |
| Type of the size of an allocated object.
|
|
typedef ptrdiff_t | difference_type |
| Type of the difference between two allocated pointers.
|
|
template<class T, size_t alignment>
class AlignedAllocator< T, alignment >
Aligned memory allocator for STL containers.
Based on https://devblogs.microsoft.com/cppblog/the-mallocator/
◆ address() [1/2]
template<class T , size_t alignment>
Get the address of an object.
Overloaded in case somebody overloaded the unary operator&() (which is pretty weird but the spec allows it)
- Parameters
-
rhs | The object to get the address of |
◆ address() [2/2]
template<class T , size_t alignment>
Get the address of an object.
Overloaded in case somebody overloaded the unary operator&() (which is pretty weird but the spec allows it)
- Parameters
-
rhs | The object to get the address of |
◆ allocate() [1/2]
template<class T , size_t alignment>
template<typename U >
T * AlignedAllocator< T, alignment >::allocate |
( |
const size_t |
n, |
|
|
const U *const |
hint |
|
) |
| |
|
inline |
Allocate an object.
- Parameters
-
n | Size in bytes |
hint | Ignored |
◆ allocate() [2/2]
template<class T , size_t alignment>
Allocate a block of memory.
- Parameters
-
n | Size in bytes (internally rounded up to our alignment) |
◆ construct()
template<class T , size_t alignment>
void AlignedAllocator< T, alignment >::construct |
( |
T *const |
p, |
|
|
const T & |
t |
|
) |
| const |
|
inline |
Construct an object in-place given a reference one.
- Parameters
-
p | Destination object |
t | Source object |
◆ deallocate() [1/2]
template<class T , size_t alignment>
Free a single object.
- Parameters
-
◆ deallocate() [2/2]
template<class T , size_t alignment>
void AlignedAllocator< T, alignment >::deallocate |
( |
T *const |
p, |
|
|
const size_t |
unused |
|
) |
| const |
|
inline |
Free a block of memory.
- Parameters
-
p | Block to free |
unused | Size of block (ignored) |
◆ max_size()
template<class T , size_t alignment>
Get the max possible allocation size the allocator supports.
(Does not necessarily mean that we have enough RAM to do so, only enough address space)
◆ operator!=()
template<class T , size_t alignment>
Check if two allocators are the same.
- Parameters
-
The documentation for this class was generated from the following file: