// based on code by Jerry Coffin (most likely Public Domain) // - rlyeh #pragma once #include #include #include #include "ltalloc.h" namespace lt { template struct allocator { typedef size_t size_type; typedef ptrdiff_t difference_type; typedef T* pointer; typedef const T* const_pointer; typedef T& reference; typedef const T& const_reference; typedef T value_type; template struct rebind { typedef allocator other; }; allocator() throw() {} allocator(const allocator&) throw() {} template allocator(const allocator&) throw(){} ~allocator() throw() {} pointer address(reference x) const { return &x; } const_pointer address(const_reference x) const { return &x; } pointer allocate(size_type s, void const * = 0) { if (0 == s) return NULL; pointer temp = (pointer)ltmalloc(s * sizeof(T)); if (temp == NULL) throw std::bad_alloc(); return temp; } void deallocate(pointer p, size_type) { ltfree(p); } size_type max_size() const throw() { return std::numeric_limits::max() / sizeof(T); } void construct(pointer p, const T& val) { new((void *)p) T(val); } void destroy(pointer p) { p->~T(); } }; }