Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
STLAlignedAllocator.h
Go to the documentation of this file.
1// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
2// SPDX-FileCopyrightText: 2021 Jorrit Rouwe
3// SPDX-License-Identifier: MIT
4
5#pragma once
6
8
10template <typename T, size_t N>
12{
13public:
14 using value_type = T;
15
17 using pointer = T *;
18 using const_pointer = const T *;
19
22 using reference = T &;
23 using const_reference = const T &;
24
25 using size_type = size_t;
26 using difference_type = ptrdiff_t;
27
29 using is_always_equal = std::true_type;
30
33
35 inline STLAlignedAllocator() = default;
36
38 template <typename T2>
40
43 {
44 return (pointer)AlignedAllocate(inN * sizeof(value_type), N);
45 }
46
48 inline void deallocate(pointer inPointer, size_type)
49 {
50 AlignedFree(inPointer);
51 }
52
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
65 template <typename T2>
66 struct rebind
67 {
69 };
70};
71
#define JPH_NAMESPACE_END
Definition Core.h:414
#define JPH_NAMESPACE_BEGIN
Definition Core.h:408
AlignedFreeFunction AlignedFree
Definition Memory.cpp:72
AlignedAllocateFunction AlignedAllocate
Definition Memory.cpp:71
STL allocator that takes care that memory is aligned to N bytes.
Definition STLAlignedAllocator.h:12
size_t size_type
Definition STLAlignedAllocator.h:25
T * pointer
Pointer to type.
Definition STLAlignedAllocator.h:17
bool operator!=(const STLAlignedAllocator< T, N > &) const
Definition STLAlignedAllocator.h:59
bool operator==(const STLAlignedAllocator< T, N > &) const
Allocators are stateless so assumed to be equal.
Definition STLAlignedAllocator.h:54
std::true_type propagate_on_container_move_assignment
Allocator supports moving.
Definition STLAlignedAllocator.h:32
ptrdiff_t difference_type
Definition STLAlignedAllocator.h:26
pointer allocate(size_type inN)
Allocate memory.
Definition STLAlignedAllocator.h:42
T value_type
Definition STLAlignedAllocator.h:14
STLAlignedAllocator()=default
Constructor.
T & reference
Definition STLAlignedAllocator.h:22
void deallocate(pointer inPointer, size_type)
Free memory.
Definition STLAlignedAllocator.h:48
STLAlignedAllocator(const STLAlignedAllocator< T2, N > &)
Constructor from other allocator.
Definition STLAlignedAllocator.h:39
const T * const_pointer
Definition STLAlignedAllocator.h:18
const T & const_reference
Definition STLAlignedAllocator.h:23
std::true_type is_always_equal
The allocator is stateless.
Definition STLAlignedAllocator.h:29
Converting to allocator for other type.
Definition STLAlignedAllocator.h:67