Sha256: fa2b0b99d9a27569591fae0c7a75b6d94e3e0dd8ee5c4ea56ef7ab0937518910
Contents?: true
Size: 1.33 KB
Versions: 21
Compression:
Stored size: 1.33 KB
Contents
// based on code by Jerry Coffin (most likely Public Domain) // - rlyeh #pragma once #include <stdlib.h> #include <new> #include <limits> #include "ltalloc.h" namespace lt { template <class T> 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 <class U> struct rebind { typedef allocator<U> other; }; allocator() throw() {} allocator(const allocator&) throw() {} template <class U> allocator(const allocator<U>&) 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<size_t>::max() / sizeof(T); } void construct(pointer p, const T& val) { new((void *)p) T(val); } void destroy(pointer p) { p->~T(); } }; }
Version data entries
21 entries across 21 versions & 1 rubygems