From 449a94d507d0974b4ff81991c2fe3cf3ceeced61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Radovan=20=C4=8Cerven=C3=BD?= <radovan.cerveny@gmail.com> Date: Mon, 18 Apr 2016 17:56:06 +0200 Subject: [PATCH] stealth_allocator fix --- .../src/allocator/StealthAllocator.hpp | 31 ++++++++++++++++--- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/alib2common/src/allocator/StealthAllocator.hpp b/alib2common/src/allocator/StealthAllocator.hpp index 8d570058ae..7154aa5160 100644 --- a/alib2common/src/allocator/StealthAllocator.hpp +++ b/alib2common/src/allocator/StealthAllocator.hpp @@ -6,15 +6,29 @@ #define STEALTH_ALLOCATOR_HPP_ #include <memory> +#include <cstddef> #include "../measurements/MeasurementNew.hpp" namespace measurements { template < typename T > -class stealth_allocator : public std::allocator < T > { +class stealth_allocator { public: + using value_type = T; using pointer = T *; - using size_type = size_t; + using const_pointer = const T *; + using reference = T &; + using const_reference = const T &; + using size_type = std::size_t; + using difference_type = std::ptrdiff_t; + + template < typename U > + struct rebind { using other = stealth_allocator < U >; }; + + stealth_allocator ( ) { } + + template < typename U > + stealth_allocator ( const stealth_allocator < U > & ) { } pointer allocate ( size_type n ) { return static_cast < pointer > ( operator new( n * sizeof ( T ), false ) ); @@ -24,11 +38,18 @@ public: operator delete( ptr, false ); } - template < typename U > - struct rebind { using other = stealth_allocator < U >; }; - }; +template < typename T, typename U > +bool operator ==( const stealth_allocator < T > &, const stealth_allocator < U > & ) { + return true; +} + +template < typename T, typename U > +bool operator !=( const stealth_allocator < T > &, const stealth_allocator < U > & ) { + return false; +} + } #endif /* STEALTH_ALLOCATOR_HPP_ */ -- GitLab