| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
#pragma once |
| 6 |
|
| 7 |
JPH_NAMESPACE_BEGIN |
| 8 |
|
| 9 |
|
| 10 |
template <typename T, size_t N> |
| 11 |
class STLAlignedAllocator |
| 12 |
{ |
| 13 |
public: |
| 14 |
using value_type = T; |
| 15 |
|
| 16 |
|
| 17 |
using pointer = T *; |
| 18 |
using const_pointer = const T *; |
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
using reference = T &; |
| 23 |
using const_reference = const T &; |
| 24 |
|
| 25 |
using size_type = size_t; |
| 26 |
using difference_type = ptrdiff_t; |
| 27 |
|
| 28 |
|
| 29 |
using is_always_equal = std::true_type; |
| 30 |
|
| 31 |
|
| 32 |
using propagate_on_container_move_assignment = std::true_type; |
| 33 |
|
| 34 |
|
| 35 |
inline STLAlignedAllocator() = default; |
| 36 |
|
| 37 |
|
| 38 |
template <typename T2> |
| 39 |
inline explicit STLAlignedAllocator(const STLAlignedAllocator<T2, N> &) { } |
| 40 |
|
| 41 |
|
| 42 |
inline pointer allocate(size_type inN) |
| 43 |
{ |
| 44 |
return (pointer)AlignedAllocate(inN * sizeof(value_type), N); |
| 45 |
} |
| 46 |
|
| 47 |
|
| 48 |
inline void deallocate(pointer inPointer, size_type) |
| 49 |
{ |
| 50 |
AlignedFree(inPointer); |
| 51 |
} |
| 52 |
|
| 53 |
|
| 54 |
inline bool operator == (const STLAlignedAllocator<T, N> &) const |
| 55 |
{ |
| 56 |
return true; |
| 57 |
} |
| 58 |
|
| 59 |
inline bool operator != (const STLAlignedAllocator<T, N> &) const |
| 60 |
{ |
| 61 |
return false; |
| 62 |
} |
| 63 |
|
| 64 |
|
| 65 |
template <typename T2> |
| 66 |
struct rebind |
| 67 |
{ |
| 68 |
using other = STLAlignedAllocator<T2, N>; |
| 69 |
}; |
| 70 |
}; |
| 71 |
|
| 72 |
JPH_NAMESPACE_END |