2 #ifndef GAINPUTALLOCATOR_H_ 3 #define GAINPUTALLOCATOR_H_ 19 enum { DefaultAlign = 0 };
26 virtual void* Allocate(
size_t size,
size_t align = DefaultAlign) = 0;
31 virtual void Deallocate(
void* ptr) = 0;
40 return new (Allocate(
sizeof(T))) T();
47 template <
class T,
class P0>
50 return new (Allocate(
sizeof(T))) T(p0);
57 template <
class T,
class P0>
60 return new (Allocate(
sizeof(T))) T(p0);
67 template <
class T,
class P0,
class P1>
68 T*
New(P0& p0, P1& p1)
70 return new (Allocate(
sizeof(T))) T(p0, p1);
77 template <
class T,
class P0,
class P1>
78 T*
New(
const P0& p0, P1& p1)
80 return new (Allocate(
sizeof(T))) T(p0, p1);
87 template <
class T,
class P0,
class P1>
88 T*
New(P0& p0,
const P1& p1)
90 return new (Allocate(
sizeof(T))) T(p0, p1);
97 template <
class T,
class P0,
class P1,
class P2>
98 T*
New(P0& p0,
const P1& p1,
const P2& p2)
100 return new (Allocate(
sizeof(T))) T(p0, p1, p2);
107 template <
class T,
class P0,
class P1,
class P2>
108 T*
New(P0& p0,
const P1& p1, P2& p2)
110 return new (Allocate(
sizeof(T))) T(p0, p1, p2);
117 template <
class T,
class P0,
class P1,
class P2,
class P3>
118 T*
New(P0& p0, P1& p1, P2& p2, P3& p3)
120 return new (Allocate(
sizeof(T))) T(p0, p1, p2, p3);
127 template <
class T,
class P0,
class P1,
class P2,
class P3>
128 T*
New(P0& p0,
const P1& p1, P2& p2, P3& p3)
130 return new (Allocate(
sizeof(T))) T(p0, p1, p2, p3);
137 template <
class T,
class P0,
class P1,
class P2,
class P3,
class P4>
138 T*
New(P0& p0, P1& p1, P2& p2, P3& p3, P4& p4)
140 return new (Allocate(
sizeof(T))) T(p0, p1, p2, p3, p4);
147 template <
class T,
class P0,
class P1,
class P2,
class P3,
class P4>
148 T*
New(P0& p0,
const P1& p1, P2& p2, P3& p3, P4& p4)
150 return new (Allocate(
sizeof(T))) T(p0, p1, p2, p3, p4);
193 template<
class K,
class V>
194 class GAINPUT_LIBEXPORT HashMap;
207 void* Allocate(
size_t size,
size_t align = DefaultAlign);
208 void Deallocate(
void* ptr);
210 size_t GetAllocateCount()
const {
return allocateCount_; }
211 size_t GetDeallocateCount()
const {
return deallocateCount_; }
212 size_t GetAllocatedMemory()
const {
return allocatedMemory_; }
218 size_t allocateCount_;
219 size_t deallocateCount_;
220 size_t allocatedMemory_;