|
#ifndef ALLOCATOR_H_INCLUDED
#define ALLOCATOR_H_INCLUDED
#include "MemManager7.h"
#include <memory>
namespace Mm {
template <class T>
class Allocator
{
public:
typedef T value_type;
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;
pointer address(reference r) const { return &r; }
const_pointer address(const_reference r) const { return &r; }
Allocator() throw() {}
// Allocator(const Allocator&) throw() {}
template <class U>
Allocator(const Allocator<U>&) throw() {}
~Allocator() throw() {}
pointer allocate(size_type n, std::allocator<void>::const_pointer hint = 0)
{
return static_cast<pointer>(Mm::Allocate(this, n * sizeof(value_type)));
}
pointer _Charalloc(size_type bytes, std::allocator<void>::const_pointer hint = 0)
{
return static_cast<pointer>(Mm::Allocate(this, bytes));
}
void deallocate(void* p, size_type n)
{
Mm::Deallocate(p, n*sizeof(T));
}
void construct(pointer p, const T& val) { new(p) T(val); }
void destroy(pointer p) { p->~T(); }
size_type max_size() const throw() { return (size_type)(-1); }
template <class U>
bool operator==(const Allocator<U>& other) const
{ return (true); }
template <class U>
bool operator!=(const Allocator<U>& other) const
{ return (false); }
template <class U>
struct rebind { typedef Allocator<U> other; };
};
typedef std::basic_string<char, std::char_traits<char>, Allocator<char> > string;
};
#endif // ALLOCATOR_H_INCLUDED
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
A compiler warns of bogasity, ignore it at your peril. Unless you've done the compiler's job yourself, don't criticize it.