25 #include <kiwano/macros.h> 39 virtual void* Alloc(
size_t size) = 0;
43 virtual void Free(
void* ptr) = 0;
56 inline void* Alloc(
size_t size)
58 return memory::GetAllocator()->Alloc(size);
63 inline void Free(
void* ptr)
65 memory::GetAllocator()->Free(ptr);
72 template <
typename _Ty>
76 typedef _Ty value_type;
78 typedef const _Ty* const_pointer;
79 typedef _Ty& reference;
80 typedef const _Ty& const_reference;
82 using size_type = size_t;
83 using difference_type = ptrdiff_t;
85 template <
class _Other>
95 template <
class _Other>
100 inline _Ty* allocate(
size_t count)
104 return static_cast<_Ty*
>(memory::Alloc(
sizeof(_Ty) * count));
109 inline void* allocate(
size_t count,
const void*)
111 return allocate(count);
114 inline void deallocate(
void* ptr,
size_t count)
119 template <
typename _UTy,
typename... _Args>
120 inline void construct(_UTy*
const ptr, _Args&&... args)
122 ::new (const_cast<void*>(static_cast<const volatile void*>(ptr))) _Ty(std::forward<_Args>(args)...);
125 template <
typename _UTy>
126 inline void destroy(_UTy* ptr)
131 size_t max_size()
const noexcept
133 return std::numeric_limits<size_t>::max() /
sizeof(_Ty);
136 _Ty* address(_Ty& val)
const noexcept
138 return std::addressof(val);
141 const _Ty* address(
const _Ty& val)
const noexcept
143 return std::addressof(val);
152 using value_type = void;
153 typedef void* pointer;
154 typedef const void* const_pointer;
156 using size_type = size_t;
157 using difference_type = ptrdiff_t;
159 template <
class _Other>
166 template <
class _Ty,
class _Other>
172 template <
class _Ty,
class _Other>
内存分配器
Definition: Allocator.h:34
分配器
Definition: Allocator.h:73
Definition: Allocator.h:86