We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent fe28c9e commit 192aa2bCopy full SHA for 192aa2b
1 file changed
MemoryPool.h
@@ -63,6 +63,10 @@ namespace CPPShift::Memory {
63
*/
64
void* allocate(size_t size);
65
66
+ // Templated allocation
67
+ template<typename T>
68
+ T* allocate(size_t instances);
69
+
70
/**
71
* Re-allocates memory in a pool
72
*
@@ -106,4 +110,10 @@ namespace CPPShift::Memory {
106
110
107
111
// Override new operators to create with memory pool
108
112
extern void* operator new(size_t size, CPPShift::Memory::MemoryPool* mp);
109
-extern void* operator new[](size_t size, CPPShift::Memory::MemoryPool* mp);
113
+extern void* operator new[](size_t size, CPPShift::Memory::MemoryPool* mp);
114
115
116
+template<typename T>
117
+inline T* allocate(size_t instances) {
118
+ return reinterpret_cast<T*>(this->allocate(instances * sizeof(T)));
119
+}
0 commit comments