Next : Containers, Previous : Allocator requirements, Top : Table of Contents


The default allocator

allocator Allocator
allocator Allocator

template 
class allocator {
public:
    typedef T* pointer;
    typedef const T* const_pointer;
    typedef T& reference;
    typedef const T& const_reference;
    typedef T value_type;
    typedef size_t size_type;
    typedef ptrdiff_t difference_type;
    allocator();
    ~allocator();
    pointer address(reference x);
    const_pointer const_address(const_reference x);
    pointer allocate(size_type n);
    void deallocate(pointer p);
    size_type init_page_size();
    size_type max_size();
};
// specialize for void:
template
class allocator<void> {
public:
    typedef void* pointer;
    typedef const void* const_pointer;

// reference-to-void members are impossible.
    typedef void value_type;
    template <class U>
    struct rebind {
      typedef allocator<U> other; 
     };
};

class allocator {
public:
    typedef void* pointer;
    allocator();
    ~allocator();
};

In addition to allocator the library vendors are expected to provide allocators for all supported memory models.


 

Top