Skip to content
Snippets Groups Projects
Commit 449a94d5 authored by Radovan Červený's avatar Radovan Červený
Browse files

stealth_allocator fix

parent 9b67e1f1
No related branches found
No related tags found
No related merge requests found
......@@ -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_ */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment