7 #ifndef STLSLABALLOCATOR_H
8 #define STLSLABALLOCATOR_H
26 allocator = make_shared<SlabAllocator>(size,
true);
29 allocator = make_shared<SlabAllocator>(memPool, size,
true);
41 void* retPtr =
allocator->do_slabs_alloc(n *
sizeof(T));
45 if (retPtr ==
nullptr) {
46 std::bad_alloc exception;
47 cout <<
"Can't allocate more from the page! TODO: add a new page!\n";
54 return allocator->do_slabs_free(p, n *
sizeof(T));
70 template <
class T,
class U>
78 template <
class T,
class U>
STLSlabAllocator(const STLSlabAllocator< U > &other)
shared_ptr< SlabAllocator > SlabAllocatorPtr
pointer allocate(size_type n, const void *=0)
SlabAllocatorPtr allocator
void deallocate(pointer p, size_type n)
void construct(pointer p, const T &val)
ptrdiff_t difference_type
STLSlabAllocator< U > other
SlabAllocatorPtr getAllocator() const
bool operator!=(const STLSlabAllocator< T > &left, const STLSlabAllocator< U > &right)
const T & const_reference
bool operator==(const STLSlabAllocator< T > &left, const STLSlabAllocator< U > &right)
STLSlabAllocator(size_t size)
STLSlabAllocator(void *memPool, size_t size)