[allocator.requirements.general]

# 16 Library introduction [[library]](./#library)

## 16.4 Library-wide requirements [[requirements]](requirements#allocator.requirements.general)

### 16.4.4 Requirements on types and expressions [[utility.requirements]](utility.requirements#allocator.requirements.general)

#### 16.4.4.6 *Cpp17Allocator* requirements [[allocator.requirements]](allocator.requirements#general)

#### 16.4.4.6.1 General [allocator.requirements.general]

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2138)

The library describes a standard set of requirements for [*allocators*](#def:allocators),
which are class-type objects that encapsulate the information about an allocation model[.](#1.sentence-1)

This information includes the knowledge of pointer types, the type of their
difference, the type of the size of objects in this allocation model, as well
as the memory allocation and deallocation primitives for it[.](#1.sentence-2)

All of the
string types ([[strings]](strings "27 Strings library")),
containers ([[containers]](containers "23 Containers library")) (except array and inplace_vector),
string buffers and string streams ([[input.output]](input.output "31 Input/output library")), and[match_results](re "28.6 Regular expressions library [re]") are parameterized in terms of
allocators[.](#1.sentence-3)

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2150)

In [[allocator.requirements]](allocator.requirements "16.4.4.6 Cpp17Allocator requirements"),

- [(2.1)](#2.1)

T, U, C denote
any cv-unqualified object type ([[basic.types.general]](basic.types.general#term.object.type "6.9.1 General")),

- [(2.2)](#2.2)

X denotes an allocator class for type T,

- [(2.3)](#2.3)

Y denotes the corresponding allocator class for type U,

- [(2.4)](#2.4)

XX denotes the type allocator_traits<X>,

- [(2.5)](#2.5)

YY denotes the type allocator_traits<Y>,

- [(2.6)](#2.6)

a, a1, a2 denote lvalues of type X,

- [(2.7)](#2.7)

u denotes the name of a variable being declared,

- [(2.8)](#2.8)

b denotes a value of type Y,

- [(2.9)](#2.9)

c denotes a pointer of type C* through which indirection is valid,

- [(2.10)](#2.10)

p denotes a value of type XX​::​pointer obtained by calling a1.allocate, where a1 == a,

- [(2.11)](#2.11)

q denotes a value of type XX​::​const_pointer obtained by conversion from a value p,

- [(2.12)](#2.12)

r denotes a value of type T& obtained by the expression *p,

- [(2.13)](#2.13)

w denotes a value of type XX​::​void_pointer obtained by conversion from a value p,

- [(2.14)](#2.14)

x denotes a value of type XX​::​const_void_pointer obtained by conversion from a value q or a value w,

- [(2.15)](#2.15)

y denotes a value of type XX​::​const_void_pointer obtained by conversion from a result value of YY​::​allocate, or else
a value of type (possibly const) std​::​nullptr_t,

- [(2.16)](#2.16)

n denotes a value of type XX​::​size_type,

- [(2.17)](#2.17)

Args denotes a template parameter pack, and

- [(2.18)](#2.18)

args denotes
a function parameter pack with the pattern Args&&[.](#2.sentence-1)

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2201)

The class template allocator_traits ([[allocator.traits]](allocator.traits "20.2.9 Allocator traits")) supplies
a uniform interface to all allocator types[.](#3.sentence-1)

This subclause
describes the requirements on allocator types
and thus on types used to instantiate allocator_traits[.](#3.sentence-2)

A requirement is optional if a default for a
given type or expression is specified[.](#3.sentence-3)

Within the standard library allocator_traits template, an optional requirement that is not supplied by an allocator is
replaced by the specified default type or expression[.](#3.sentence-4)

[*Note [1](#note-1)*:

There are no program-defined specializations of allocator_traits[.](#3.sentence-5)

â *end note*]

[ð](#itemdecl:1)

`typename X::pointer
`

[4](#4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2221)

*Remarks*: Default: T*

[ð](#itemdecl:2)

`typename X::const_pointer
`

[5](#5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2231)

*Mandates*: XX​::​pointer is convertible to XX​::​const_pointer[.](#5.sentence-1)

[6](#6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2235)

*Remarks*: Default: pointer_traits<XX​::​pointer>​::​rebind<const T>

[ð](#itemdecl:3)

`typename X::void_pointer
typename Y::void_pointer
`

[7](#7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2246)

*Mandates*: XX​::​pointer is convertible to XX​::​void_pointer[.](#7.sentence-1)

XX​::​void_pointer and YY​::​void_pointer are the same type[.](#7.sentence-2)

[8](#8)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2251)

*Remarks*: Default:pointer_traits<XX​::​pointer>​::​rebind<void>

[ð](#itemdecl:4)

`typename X::const_void_pointer
typename Y::const_void_pointer
`

[9](#9)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2263)

*Mandates*: XX​::​pointer, XX​::​const_pointer, and XX​::​void_pointer are convertible to XX​::​const_void_pointer[.](#9.sentence-1)

XX​::​const_void_pointer and YY​::​const_void_pointer are the same type[.](#9.sentence-2)

[10](#10)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2270)

*Remarks*: Default:pointer_traits<XX​::​pointer>​::​rebind<const void>

[ð](#itemdecl:5)

`typename X::value_type
`

[11](#11)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2281)

*Result*: Identical to T[.](#11.sentence-1)

[ð](#itemdecl:6)

`typename X::size_type
`

[12](#12)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2291)

*Result*: An unsigned integer type
that can represent the size of the largest object in the allocation model[.](#12.sentence-1)

[13](#13)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2296)

*Remarks*: Default:make_unsigned_t<XX​::​difference_type>

[ð](#itemdecl:7)

`typename X::difference_type
`

[14](#14)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2307)

*Result*: A signed integer type that can represent
the difference between any two pointers in the allocation model[.](#14.sentence-1)

[15](#15)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2312)

*Remarks*: Default:pointer_traits<XX​::​pointer>​::​difference_type

[ð](#itemdecl:8)

`typename X::rebind<U>::other
`

[16](#16)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2323)

*Result*: Y

[17](#17)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2327)

*Postconditions*: For all U (including T),YY​::​rebind_alloc<T> is X[.](#17.sentence-1)

[18](#18)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2332)

*Remarks*: If Allocator is a class template instantiation of the formSomeAllocator<T, Args>, where Args is zero or more type
arguments, and Allocator does not supply a rebind member
template, the standard allocator_traits template usesSomeAllocator<U, Args> in place of Allocator​::​rebind<U>​::​other by default[.](#18.sentence-1)

For allocator types that are not template instantiations of the
above form, no default is provided[.](#18.sentence-2)

[19](#19)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2342)

[*Note [2](#note-2)*:

The member class template rebind of X is
effectively a typedef template[.](#19.sentence-1)

In general, if
the name Allocator is bound to SomeAllocator<T>, thenAllocator​::​rebind<U>​::​other is the same type asSomeAllocator<U>, whereSomeAllocator<T>​::​value_type is T andSomeAllocator<U>​::​value_type is U[.](#19.sentence-2)

â *end note*]

[ð](#itemdecl:9)

`*p
`

[20](#20)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2360)

*Result*: T&

[ð](#itemdecl:10)

`*q
`

[21](#21)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2370)

*Result*: const T&

[22](#22)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2374)

*Postconditions*: *q refers to the same object as *p[.](#22.sentence-1)

[ð](#itemdecl:11)

`p->m
`

[23](#23)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2384)

*Result*: Type of T​::​m[.](#23.sentence-1)

[24](#24)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2388)

*Preconditions*: (*p).m is well-defined[.](#24.sentence-1)

[25](#25)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2392)

*Effects*: Equivalent to (*p).m[.](#25.sentence-1)

[ð](#itemdecl:12)

`q->m
`

[26](#26)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2402)

*Result*: Type of T​::​m[.](#26.sentence-1)

[27](#27)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2406)

*Preconditions*: (*q).m is well-defined[.](#27.sentence-1)

[28](#28)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2410)

*Effects*: Equivalent to (*q).m[.](#28.sentence-1)

[ð](#itemdecl:13)

`static_cast<XX::pointer>(w)
`

[29](#29)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2420)

*Result*: XX​::​pointer

[30](#30)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2424)

*Postconditions*: static_cast<XX​::​pointer>(w) == p[.](#30.sentence-1)

[ð](#itemdecl:14)

`static_cast<XX::const_pointer>(x)
`

[31](#31)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2434)

*Result*: XX​::​const_pointer

[32](#32)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2438)

*Postconditions*: static_cast<XX​::​const_pointer>(x) == q[.](#32.sentence-1)

[ð](#itemdecl:15)

`pointer_traits<XX::pointer>::pointer_to(r)
`

[33](#33)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2448)

*Result*: XX​::​pointer

[34](#34)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2452)

*Postconditions*: Same as p[.](#34.sentence-1)

[ð](#itemdecl:16)

`a.allocate(n)
`

[35](#35)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2462)

*Result*: XX​::​pointer

[36](#36)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2466)

*Effects*: Memory is allocated for an array of n T and such an object is created
but array elements are not constructed[.](#36.sentence-1)

[*Example [1](#example-1)*:

When reusing storage denoted by some pointer value p,launder(reinterpret_cast<T*>(new (p) byte[n * sizeof(T)])) can be used to implicitly create a suitable array object
and obtain a pointer to it[.](#36.sentence-2)

â *end example*]

[37](#37)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2478)

*Throws*: allocate may throw an appropriate exception[.](#37.sentence-1)

[38](#38)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2482)

[*Note [3](#note-3)*:

It is intended that a.allocate be an efficient means
of allocating a single object of type T, even when sizeof(T) is small[.](#38.sentence-1)

That is, there is no need for a container to maintain its own
free list[.](#38.sentence-2)

â *end note*]

[39](#39)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2490)

*Remarks*: If n == 0, the return value is unspecified[.](#39.sentence-1)

[ð](#itemdecl:17)

`a.allocate(n, y)
`

[40](#40)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2500)

*Result*: XX​::​pointer

[41](#41)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2504)

*Effects*: Same as a.allocate(n)[.](#41.sentence-1)

The use of y is unspecified, but it is intended as an aid to locality[.](#41.sentence-2)

[42](#42)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2509)

*Remarks*: Default: a.allocate(n)

[ð](#itemdecl:18)

`a.allocate_at_least(n)
`

[43](#43)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2519)

*Result*: allocation_result<XX​::​pointer, XX​::​size_type>

[44](#44)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2523)

*Returns*: allocation_result<XX​::​pointer, XX​::​size_type>{ptr, count} where ptr is memory allocated for an array of count T and such an object is created but array elements are not constructed,
such that count â¥ n[.](#44.sentence-1)

If n == 0, the return value is unspecified[.](#44.sentence-2)

[45](#45)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2531)

*Throws*: allocate_at_least may throw an appropriate exception[.](#45.sentence-1)

[46](#46)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2535)

*Remarks*: Default: {a.allocate(n), n}[.](#46.sentence-1)

[ð](#itemdecl:19)

`a.deallocate(p, n)
`

[47](#47)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2545)

*Result*: (not used)

[48](#48)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2549)

*Preconditions*: 

- [(48.1)](#48.1)

  If p is memory
that was obtained by a call to a.allocate_at_least,
let ret be the value returned andreq be the value passed as the first argument of that call[.](#48.1.sentence-1)
  p is equal to ret.ptr andn is a value such thatreq â¤ n â¤ ret.count[.](#48.1.sentence-2)

- [(48.2)](#48.2)

  Otherwise, p is a pointer value obtained from allocate[.](#48.2.sentence-1)
  n equals the value passed as the first argument
to the invocation of allocate which returned p[.](#48.2.sentence-2)

p has not been invalidated by
an intervening call to deallocate[.](#48.sentence-2)

[49](#49)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2568)

*Throws*: Nothing[.](#49.sentence-1)

[ð](#itemdecl:20)

`a.max_size()
`

[50](#50)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2578)

*Result*: XX​::​size_type

[51](#51)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2582)

*Returns*: The largest value n that can meaningfully be passed to a.allocate(n)[.](#51.sentence-1)

[52](#52)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2586)

*Remarks*: Default:numeric_limits<size_type>​::​max() / sizeof(value_type)

[ð](#itemdecl:21)

`a1 == a2
`

[53](#53)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2597)

*Result*: bool

[54](#54)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2601)

*Returns*: true only if storage allocated from each can
be deallocated via the other[.](#54.sentence-1)

[55](#55)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2606)

*Throws*: Nothing[.](#55.sentence-1)

[56](#56)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2610)

*Remarks*: operator== shall be reflexive, symmetric,
and transitive[.](#56.sentence-1)

[ð](#itemdecl:22)

`a1 != a2
`

[57](#57)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2621)

*Result*: bool

[58](#58)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2625)

*Returns*: !(a1 == a2)[.](#58.sentence-1)

[ð](#itemdecl:23)

`a == b
`

[59](#59)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2635)

*Result*: bool

[60](#60)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2639)

*Returns*: a == YY​::​rebind_alloc<T>(b)[.](#60.sentence-1)

[ð](#itemdecl:24)

`a != b
`

[61](#61)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2649)

*Result*: bool

[62](#62)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2653)

*Returns*: !(a == b)[.](#62.sentence-1)

[ð](#itemdecl:25)

`X u(a);
X u = a;
`

[63](#63)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2664)

*Postconditions*: u == a

[64](#64)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2668)

*Throws*: Nothing[.](#64.sentence-1)

[ð](#itemdecl:26)

`X u(b);
`

[65](#65)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2678)

*Postconditions*: Y(u) == b and u == X(b)[.](#65.sentence-1)

[66](#66)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2682)

*Throws*: Nothing[.](#66.sentence-1)

[ð](#itemdecl:27)

`X u(std::move(a));
X u = std::move(a);
`

[67](#67)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2693)

*Postconditions*: The value of a is unchanged and is equal to u[.](#67.sentence-1)

[68](#68)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2697)

*Throws*: Nothing[.](#68.sentence-1)

[ð](#itemdecl:28)

`X u(std::move(b));
`

[69](#69)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2707)

*Postconditions*: u is equal to the prior value of X(b)[.](#69.sentence-1)

[70](#70)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2711)

*Throws*: Nothing[.](#70.sentence-1)

[ð](#itemdecl:29)

`a.construct(c, args...)
`

[71](#71)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2721)

*Result*: (not used)

[72](#72)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2725)

*Effects*: Constructs an object of type C at c[.](#72.sentence-1)

[73](#73)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2729)

*Remarks*: Default:construct_at(c, std​::​forward<Args>(args)...)

[ð](#itemdecl:30)

`a.destroy(c)
`

[74](#74)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2740)

*Result*: (not used)

[75](#75)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2744)

*Effects*: Destroys the object at c[.](#75.sentence-1)

[76](#76)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2748)

*Remarks*: Default: destroy_at(c)

[ð](#itemdecl:31)

`a.select_on_container_copy_construction()
`

[77](#77)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2758)

*Result*: X

[78](#78)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2762)

*Returns*: Typically returns either a or X()[.](#78.sentence-1)

[79](#79)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2766)

*Remarks*: Default: return a;

[ð](#itemdecl:32)

`typename X::propagate_on_container_copy_assignment
`

[80](#80)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2776)

*Result*: Identical to or derived from true_type or false_type[.](#80.sentence-1)

[81](#81)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2780)

*Returns*: true_type only if an allocator of type X should be copied
when the client container is copy-assigned;
if so, X shall meet
the [*Cpp17CopyAssignable*](utility.arg.requirements#:Cpp17CopyAssignable "16.4.4.2 Template argument requirements [utility.arg.requirements]") requirements (Table [34](utility.arg.requirements#tab:cpp17.copyassignable "Table 34: Cpp17CopyAssignable requirements (in addition to Cpp17MoveAssignable)")) and
the copy operation shall not throw exceptions[.](#81.sentence-1)

[82](#82)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2788)

*Remarks*: Default: false_type

[ð](#itemdecl:33)

`typename X::propagate_on_container_move_assignment
`

[83](#83)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2798)

*Result*: Identical to or derived from true_type or false_type[.](#83.sentence-1)

[84](#84)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2802)

*Returns*: true_type only if an allocator of type X should be moved
when the client container is move-assigned;
if so, X shall meet
the [*Cpp17MoveAssignable*](utility.arg.requirements#:Cpp17MoveAssignable "16.4.4.2 Template argument requirements [utility.arg.requirements]") requirements (Table [33](utility.arg.requirements#tab:cpp17.moveassignable "Table 33: Cpp17MoveAssignable requirements")) and
the move operation shall not throw exceptions[.](#84.sentence-1)

[85](#85)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2810)

*Remarks*: Default: false_type

[ð](#itemdecl:34)

`typename X::propagate_on_container_swap
`

[86](#86)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2820)

*Result*: Identical to or derived from true_type or false_type[.](#86.sentence-1)

[87](#87)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2824)

*Returns*: true_type only if an allocator of type X should be swapped
when the client container is swapped;
if so,X shall meet the [*Cpp17Swappable*](swappable.requirements#:Cpp17Swappable "16.4.4.3 Swappable requirements [swappable.requirements]") requirements ([[swappable.requirements]](swappable.requirements "16.4.4.3 Swappable requirements")) and
the swap operation shall not throw exceptions[.](#87.sentence-1)

[88](#88)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2832)

*Remarks*: Default: false_type

[ð](#itemdecl:35)

`typename X::is_always_equal
`

[89](#89)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2842)

*Result*: Identical to or derived from true_type or false_type[.](#89.sentence-1)

[90](#90)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2846)

*Returns*: true_type only if the expression a1 == a2 is guaranteed
to be true for any two (possibly const) valuesa1, a2 of type X[.](#90.sentence-1)

[91](#91)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2852)

*Remarks*: Default: is_empty<X>​::​type

[92](#92)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2857)

An allocator type X shall meet the[*Cpp17CopyConstructible*](utility.arg.requirements#:Cpp17CopyConstructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") requirements (Table [32](utility.arg.requirements#tab:cpp17.copyconstructible "Table 32: Cpp17CopyConstructible requirements (in addition to Cpp17MoveConstructible)"))[.](#92.sentence-1)

The XX​::​pointer, XX​::​const_pointer, XX​::​void_pointer, andXX​::​const_void_pointer types shall meet the*Cpp17NullablePointer* requirements (Table [36](nullablepointer.requirements#tab:cpp17.nullablepointer "Table 36: Cpp17NullablePointer requirements"))[.](#92.sentence-2)

No constructor,
comparison operator function, copy operation, move operation, or swap operation on
these pointer types shall exit via an exception[.](#92.sentence-3)

XX​::​pointer and XX​::​const_pointer shall also
meet the requirements for
a [*Cpp17RandomAccessIterator*](random.access.iterators#:Cpp17RandomAccessIterator "24.3.5.7 Random access iterators [random.access.iterators]") ([[random.access.iterators]](random.access.iterators "24.3.5.7 Random access iterators")) and
the additional requirement that, when p and (p + n) are
dereferenceable pointer values for some integral value n,addressof(*(p + n)) == addressof(*p) + n is true[.](#92.sentence-4)

[93](#93)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2875)

Let x1 and x2 denote objects of (possibly different) typesXX​::​void_pointer, XX​::​const_void_pointer, XX​::​pointer,
or XX​::​const_pointer[.](#93.sentence-1)

Then, x1 and x2 are[*equivalently-valued*](#def:equivalently-valued "16.4.4.6.1 General [allocator.requirements.general]") pointer values, if and only if both x1 and x2 can be explicitly converted to the two corresponding objects px1 and px2 of type XX​::​const_pointer, using a sequence of static_casts
using only these four types, and the expression px1 == px2 evaluates to true[.](#93.sentence-2)

[94](#94)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2885)

Let w1 and w2 denote objects of type XX​::​void_pointer[.](#94.sentence-1)

Then for the expressionsw1 == w2
w1 != w2 either or both objects may be replaced by an equivalently-valued object of typeXX​::​const_void_pointer with no change in semantics[.](#94.sentence-2)

[95](#95)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2895)

Let p1 and p2 denote objects of type XX​::​pointer[.](#95.sentence-1)

Then for the expressionsp1 == p2
p1 != p2
p1 < p2
p1 <= p2
p1 >= p2
p1 > p2
p1 - p2 either or both objects may be replaced by an equivalently-valued object of typeXX​::​const_pointer with no change in semantics[.](#95.sentence-2)

[96](#96)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2910)

An allocator may constrain the types on which it can be instantiated and the
arguments for which its construct or destroy members may be
called[.](#96.sentence-1)

If a type cannot be used with a particular allocator, the allocator
class or the call to construct or destroy may fail to instantiate[.](#96.sentence-2)

[97](#97)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2916)

If the alignment associated with a specific over-aligned type is not
supported by an allocator, instantiation of the allocator for that type may
fail[.](#97.sentence-1)

The allocator also may silently ignore the requested alignment[.](#97.sentence-2)

[*Note [4](#note-4)*:

Additionally, the member function allocate for that type can fail by throwing an object of typebad_alloc[.](#97.sentence-3)

â *end note*]

[98](#98)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2926)

[*Example [2](#example-2)*:

The following is an allocator class template supporting the minimal
interface that meets the requirements of [allocator.requirements.general]:template<class T>struct SimpleAllocator {using value_type = T;
 SimpleAllocator(*ctor args*); template<class U> SimpleAllocator(const SimpleAllocator<U>& other);

 T* allocate(std::size_t n); void deallocate(T* p, std::size_t n); template<class U> bool operator==(const SimpleAllocator<U>& rhs) const;};

â *end example*]

[99](#99)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2946)

The following exposition-only concept defines
the minimal requirements on an Allocator type[.](#99.sentence-1)

template<class Alloc>concept [*simple-allocator*](#concept:simple-allocator "16.4.4.6.1 General [allocator.requirements.general]") =requires(Alloc alloc, size_t n) {{ *alloc.allocate(n) } -> [same_as](concept.same#concept:same_as "18.4.2 Concept same_­as [concept.same]")<typename Alloc::value_type&>; { alloc.deallocate(alloc.allocate(n), n) }; } &&[copy_constructible](concept.copyconstructible#concept:copy_constructible "18.4.14 Concept copy_­constructible [concept.copyconstructible]")<Alloc> &&[equality_comparable](concept.equalitycomparable#concept:equality_comparable "18.5.4 Concept equality_­comparable [concept.equalitycomparable]")<Alloc>;

A type Alloc models [*simple-allocator*](#concept:simple-allocator "16.4.4.6.1 General [allocator.requirements.general]") if it meets the requirements of [allocator.requirements.general][.](#99.sentence-2)
