Essential Tools Module User's Guide : Chapter 12 Advanced Topics : Using Custom Allocators : Template Functions
Template Functions
Allocator class templates must meet all the above requirements. They must also provide these other member functions.
Constructors
my_allocator() throw();
my_allocator (const allocator&) throw ();
template <class U>
my_allocator(const my_allocator<U>&);
Destructor
~my_allocator();
Assignment operators
template <class U>
my_allocator& operator=(const my_allocator<U>&) throw();
Public Member Functions
pointer address(reference r) const;
Returns the address of r as a pointer type. This function and the following function are used to convert references to pointers.
const_pointer address(const_reference r) const;
Returns the address of r as a const_pointer type.
pointer allocate(size_type n,
allocator<U>::const_pointer hint=0);
Allocates storage for n values of T. Uses the value of hint to optimize storage placement, if possible.
void deallocate(pointer);
Deallocates storage obtained by a call to allocate.
size_type max_size();
Returns the largest possible storage available through a call to allocate.
void construct(pointer p, const_reference val);
Constructs an object of type T at the location of p, using the value of val in the call to the constructor for T.
void destroy(pointer p);
Calls the destructor on the value pointed to by p.