Annex D (normative) Compatibility features [depr]

D.9 The default allocator [depr.default.allocator]

The following members and explicit class template specialization are defined in addition to those specified in [default.allocator]:

namespace std {
  // specialize for void:
  template <> class allocator<void> {
  public:
    using value_type    = void;
    using pointer       = void*;
    using const_pointer = const void*;
    // reference-to-void members are impossible.

    template <class U> struct rebind { using other = allocator<U>; };
  };

  template <class T> class allocator {
   public:
    using size_type       = size_t;
    using difference_type = ptrdiff_t;
    using pointer         = T*;
    using const_pointer   = const T*;
    using reference       = T&;
    using const_reference = const T&;
    template <class U> struct rebind { using other = allocator<U>; };

    T* address(T& x) const noexcept;
    const T* address(const T& x) const noexcept;

    T* allocate(size_t n, const void* hint);

    template<class U, class... Args>
      void construct(U* p, Args&&... args);
    template <class U>
      void destroy(U* p);

    size_t max_size() const noexcept;
  };
}

T* address(T& x) const noexcept; const T* address(const T& x) const noexcept;

Returns: addressof(x).

T* allocate(size_t n, const void* hint);

Returns: A pointer to the initial element of an array of storage of size n * sizeof(T), aligned appropriately for objects of type T. It is implementation-defined whether over-aligned types are supported ([basic.align]).

Remarks: The storage is obtained by calling ​::​operator new(std​::​size_­t) ([new.delete]), but it is unspecified when or how often this function is called.

Throws: bad_­alloc if the storage cannot be obtained.

template <class U, class... Args> void construct(U* p, Args&&... args);

Effects: As if by: ​::​new((void *)p) U(std​::​forward<Args>(args)...);

template <class U> void destroy(U* p);

Effects: As if by p->~U().

size_t max_size() const noexcept;

Returns: The largest value N for which the call allocate(N, 0) might succeed.