Standard C++ Library Class Reference
template<class T, class U> typename types<T>::pointer
allocate (size_type n, typename types<U>::const_pointer p = 0)
Allocate storage. Returns a pointer to the first element in a block of storage n*sizeof(T) bytes in size. The block will be
aligned appropriately for objects of type T. Throws the exception bad_alloc if the storage is unavailable. This function
uses operator new(size_t). The second parameter p can be used by an allocator to localize memory allocation, but the
default allocator does not use it.
template<class T>
void deallocate( typename types<T>::pointer p)
Deallocate the storage indicated by p. The storage must have been obtained by a call to allocate.
template<class T>
size_type max_size () const;
Returns the largest size for which a call to allocate might succeed.
template <class T1, class T2>
void construct (T1* p, const T2& val);
Construct an object of type T2 with the inital value of val at the location specified by p. This function calls the
placement new operator.
template <class T>
void destroy (T* p)
Call the destructor on the object pointed to by p, but do not delete.
Alternate Interface
class allocator
{
public:
typedef size_t size_type ;
typedef ptrdiff_t difference_type ;
allocator ();
~allocator (); .
void * allocate (size_type, void * = 0);
void deallocate (void*);
};
template <class Allocator,class T>
class allocator_interface .
{
public:
typedef Allocator allocator_type ;
typedef T* pointer ; .
typedef const T* const_pointer ;
typedef T& reference ; .
typedef const T& const_reference ;
typedef T value_type ; .
typedef typename Allocator::size_type size_type ;
typedef typename Allocator::size_type difference_type ;
protected:
allocator_type* alloc_;
public:
allocator_interface ();
allocator_interface (Allocator*);
void alloc (Allocator*);
pointer address (T& x);
size_type max_size () const;
pointer allocate (size_type, pointer = 0);
void deallocate (pointer);
void construct (pointer, const T&);