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 inline STLAlignedAllocator() = default;
30
32 template <typename T2>
34
37 {
38 return (pointer)AlignedAllocate(inN * sizeof(value_type), N);
39 }
40
42 inline void deallocate(pointer inPointer, size_type)
43 {
44 AlignedFree(inPointer);
45 }
46
48 inline bool operator == (const STLAlignedAllocator<T, N> &) const
49 {
50 return true;
51 }
52
53 inline bool operator != (const STLAlignedAllocator<T, N> &) const
54 {
55 return false;
56 }
57
59 template <typename T2>
60 struct rebind
61 {
63 };
64};
65
#define JPH_NAMESPACE_END
Definition: Core.h:367
#define JPH_NAMESPACE_BEGIN
Definition: Core.h:361
AlignedFreeFunction AlignedFree
Definition: Memory.cpp:62
AlignedAllocateFunction AlignedAllocate
Definition: Memory.cpp:61
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:53
bool operator==(const STLAlignedAllocator< T, N > &) const
Allocators are stateless so assumed to be equal.
Definition: STLAlignedAllocator.h:48
ptrdiff_t difference_type
Definition: STLAlignedAllocator.h:26
pointer allocate(size_type inN)
Allocate memory.
Definition: STLAlignedAllocator.h:36
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:42
STLAlignedAllocator(const STLAlignedAllocator< T2, N > &)
Constructor from other allocator.
Definition: STLAlignedAllocator.h:33
const T * const_pointer
Definition: STLAlignedAllocator.h:18
const T & const_reference
Definition: STLAlignedAllocator.h:23
Converting to allocator for other type.
Definition: STLAlignedAllocator.h:61