--- parser3/src/lib/gc/include/gc_allocator.h 2012/04/19 19:41:29 1.2 +++ parser3/src/lib/gc/include/gc_allocator.h 2020/12/14 23:27:05 1.3 @@ -39,7 +39,6 @@ #define GC_ALLOCATOR_H -#include "gc.h" #include // for placement new #if defined(__GNUC__) @@ -123,9 +122,7 @@ public: // the return value is when GC_n == 0. GC_Tp* allocate(size_type GC_n, const void* = 0) { GC_type_traits traits; - return static_cast - (GC_selective_alloc(GC_n * sizeof(GC_Tp), - traits.GC_is_ptr_free)); + return static_cast (GC_selective_alloc(GC_n * sizeof(GC_Tp), traits.GC_is_ptr_free)); } // __p is not permitted to be a null pointer. @@ -164,82 +161,5 @@ inline bool operator!=(const gc_allocato { return false; } - -/* - * And the public traceable_allocator class. - */ - -// Note that we currently don't specialize the pointer-free case, since a -// pointer-free traceable container doesn't make that much sense, -// though it could become an issue due to abstraction boundaries. -template -class traceable_allocator { -public: - typedef size_t size_type; - typedef ptrdiff_t difference_type; - typedef GC_Tp* pointer; - typedef const GC_Tp* const_pointer; - typedef GC_Tp& reference; - typedef const GC_Tp& const_reference; - typedef GC_Tp value_type; - - template struct rebind { - typedef traceable_allocator other; - }; - - traceable_allocator() throw() {} - traceable_allocator(const traceable_allocator&) throw() {} -# if !(GC_NO_MEMBER_TEMPLATES || 0 < _MSC_VER && _MSC_VER <= 1200) - // MSVC++ 6.0 do not support member templates - template traceable_allocator - (const traceable_allocator&) throw() {} -# endif - ~traceable_allocator() throw() {} - - pointer address(reference GC_x) const { return &GC_x; } - const_pointer address(const_reference GC_x) const { return &GC_x; } - - // GC_n is permitted to be 0. The C++ standard says nothing about what - // the return value is when GC_n == 0. - GC_Tp* allocate(size_type GC_n, const void* = 0) { - return static_cast(GC_MALLOC_UNCOLLECTABLE(GC_n * sizeof(GC_Tp))); - } - - // __p is not permitted to be a null pointer. - void deallocate(pointer __p, size_type GC_ATTR_UNUSED GC_n) - { GC_FREE(__p); } - - size_type max_size() const throw() - { return size_t(-1) / sizeof(GC_Tp); } - - void construct(pointer __p, const GC_Tp& __val) { new(__p) GC_Tp(__val); } - void destroy(pointer __p) { __p->~GC_Tp(); } -}; - -template<> -class traceable_allocator { - typedef size_t size_type; - typedef ptrdiff_t difference_type; - typedef void* pointer; - typedef const void* const_pointer; - typedef void value_type; - - template struct rebind { - typedef traceable_allocator other; - }; -}; - - -template -inline bool operator==(const traceable_allocator&, const traceable_allocator&) -{ - return true; -} - -template -inline bool operator!=(const traceable_allocator&, const traceable_allocator&) -{ - return false; -} #endif /* GC_ALLOCATOR_H */