[container.requirements] # 23 Containers library [[containers]](./#containers) ## 23.2 Requirements [container.requirements] ### [23.2.1](#pre) Preamble [[container.requirements.pre]](container.requirements.pre) [1](#pre-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L40) Containers are objects that store other objects[.](#pre-1.sentence-1) They control allocation and deallocation of these objects through constructors, destructors, insert and erase operations[.](#pre-1.sentence-2) [2](#pre-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L45) All of the complexity requirements in this Clause are stated solely in terms of the number of operations on the contained objects[.](#pre-2.sentence-1) [*Example [1](#pre-example-1)*: The copy constructor of typevector> has linear complexity, even though the complexity of copying each containedvector is itself linear[.](#pre-2.sentence-2) — *end example*] [3](#pre-3) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L57) Allocator-aware containers ([[container.alloc.reqmts]](#container.alloc.reqmts "23.2.2.5 Allocator-aware containers")) other than basic_string construct elements using the functionallocator_traits​::​rebind_traits​::​​construct and destroy elements using the functionallocator_traits​::​rebind_traits​::​​destroy ([[allocator.traits.members]](allocator.traits.members "20.2.9.3 Static member functions")), where U is either allocator_type​::​value_type or an internal type used by the container[.](#pre-3.sentence-1) These functions are called only for the container's element type, not for internal types used by the container[.](#pre-3.sentence-2) [*Note [1](#pre-note-1)*: This means, for example, that a node-based container would need to construct nodes containing aligned buffers and call construct to place the element into the buffer[.](#pre-3.sentence-3) — *end note*] ### [23.2.2](#general) General containers [[container.requirements.general]](container.requirements.general) #### [23.2.2.1](#container.intro.reqmts) Introduction [[container.intro.reqmts]](container.intro.reqmts) [1](#container.intro.reqmts-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L77) In [[container.requirements.general]](#general "23.2.2 General containers"), - [(1.1)](#container.intro.reqmts-1.1) X denotes a container class containing objects of type T, - [(1.2)](#container.intro.reqmts-1.2) a denotes a value of type X, - [(1.3)](#container.intro.reqmts-1.3) b and c denote values of type (possibly const) X, - [(1.4)](#container.intro.reqmts-1.4) i and j denote values of type (possibly const) X​::​iterator, - [(1.5)](#container.intro.reqmts-1.5) u denotes an identifier, - [(1.6)](#container.intro.reqmts-1.6) v denotes an lvalue of type (possibly const) X or an rvalue of type const X, - [(1.7)](#container.intro.reqmts-1.7) s and t denote non-const lvalues of type X, and - [(1.8)](#container.intro.reqmts-1.8) rv denotes a non-const rvalue of type X[.](#container.intro.reqmts-1.sentence-1) [2](#container.intro.reqmts-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L99) The following exposition-only concept is used in the definition of containers:templateconcept [*container-compatible-range*](#concept:container-compatible-range "23.2.2.1 Introduction [container.intro.reqmts]") = // *exposition only* ranges::[input_range](range.refinements#concept:input_range "25.4.6 Other range refinements [range.refinements]") && [convertible_to](concept.convertible#concept:convertible_to "18.4.4 Concept convertible_­to [concept.convertible]"), T>; #### [23.2.2.2](#container.reqmts) Container requirements [[container.reqmts]](container.reqmts) [1](#container.reqmts-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L132) A type X meets the [*container*](#def:container "23.2.2.2 Container requirements [container.reqmts]") requirements if the following types, statements, and expressions are well-formed and have the specified semantics[.](#container.reqmts-1.sentence-1) [🔗](#lib:value_type,containers) `typename X::value_type ` [2](#container.reqmts-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L143) *Result*: T [3](#container.reqmts-3) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L147) *Preconditions*: T is *Cpp17Erasable* from X (see [[container.alloc.reqmts]](#container.alloc.reqmts "23.2.2.5 Allocator-aware containers"), below)[.](#container.reqmts-3.sentence-1) [🔗](#lib:reference,containers) `typename X::reference ` [4](#container.reqmts-4) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L159) *Result*: T& [🔗](#lib:const_reference,containers) `typename X::const_reference ` [5](#container.reqmts-5) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L170) *Result*: const T& [🔗](#lib:iterator,containers) `typename X::iterator ` [6](#container.reqmts-6) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L181) *Result*: A type that meets the forward iterator requirements ([[forward.iterators]](forward.iterators "24.3.5.5 Forward iterators")) with value type T[.](#container.reqmts-6.sentence-1) The type X​::​iterator is convertible to X​::​const_iterator[.](#container.reqmts-6.sentence-2) [🔗](#lib:const_iterator,containers) `typename X::const_iterator ` [7](#container.reqmts-7) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L194) *Result*: A type that meets the requirements of a constant iterator and those of a forward iterator with value type T[.](#container.reqmts-7.sentence-1) [🔗](#lib:difference_type,containers) `typename X::difference_type ` [8](#container.reqmts-8) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L206) *Result*: A signed integer type, identical to the difference type ofX​::​iterator and X​::​const_iterator[.](#container.reqmts-8.sentence-1) [🔗](#lib:size_type,containers) `typename X::size_type ` [9](#container.reqmts-9) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L219) *Result*: An unsigned integer type that can represent any non-negative value of X​::​difference_type[.](#container.reqmts-9.sentence-1) [🔗](#container.reqmts-itemdecl:8) `X u; X u = X(); ` [10](#container.reqmts-10) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L231) *Postconditions*: u.empty() [11](#container.reqmts-11) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L235) *Complexity*: Constant[.](#container.reqmts-11.sentence-1) [🔗](#container.reqmts-itemdecl:9) `X u(v); X u = v; ` [12](#container.reqmts-12) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L246) *Preconditions*: T is *Cpp17CopyInsertable* into X (see below)[.](#container.reqmts-12.sentence-1) [13](#container.reqmts-13) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L250) *Postconditions*: u == v[.](#container.reqmts-13.sentence-1) [14](#container.reqmts-14) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L254) *Complexity*: Linear[.](#container.reqmts-14.sentence-1) [🔗](#container.reqmts-itemdecl:10) `X u(rv); X u = rv; ` [15](#container.reqmts-15) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L265) *Postconditions*: u is equal to the value that rv had before this construction[.](#container.reqmts-15.sentence-1) [16](#container.reqmts-16) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L269) *Complexity*: Linear for array and inplace_vector and constant for all other standard containers[.](#container.reqmts-16.sentence-1) [🔗](#lib:operator=,containers) `t = v; ` [17](#container.reqmts-17) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L280) *Result*: X&[.](#container.reqmts-17.sentence-1) [18](#container.reqmts-18) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L284) *Postconditions*: t == v[.](#container.reqmts-18.sentence-1) [19](#container.reqmts-19) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L288) *Complexity*: Linear[.](#container.reqmts-19.sentence-1) [🔗](#container.reqmts-itemdecl:12) `t = rv ` [20](#container.reqmts-20) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L298) *Result*: X&[.](#container.reqmts-20.sentence-1) [21](#container.reqmts-21) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L302) *Effects*: All existing elements of t are either move assigned to or destroyed[.](#container.reqmts-21.sentence-1) [22](#container.reqmts-22) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L306) *Postconditions*: If t and rv do not refer to the same object,t is equal to the value that rv had before this assignment[.](#container.reqmts-22.sentence-1) [23](#container.reqmts-23) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L311) *Complexity*: Linear[.](#container.reqmts-23.sentence-1) [🔗](#container.reqmts-itemdecl:13) `a.~X() ` [24](#container.reqmts-24) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L321) *Result*: void[.](#container.reqmts-24.sentence-1) [25](#container.reqmts-25) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L325) *Effects*: Destroys every element of a; any memory obtained is deallocated[.](#container.reqmts-25.sentence-1) [26](#container.reqmts-26) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L329) *Complexity*: Linear[.](#container.reqmts-26.sentence-1) [🔗](#lib:begin,containers) `b.begin() ` [27](#container.reqmts-27) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L340) *Result*: iterator;const_iterator for constant b[.](#container.reqmts-27.sentence-1) [28](#container.reqmts-28) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L345) *Returns*: An iterator referring to the first element in the container[.](#container.reqmts-28.sentence-1) [29](#container.reqmts-29) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L349) *Complexity*: Constant[.](#container.reqmts-29.sentence-1) [🔗](#lib:end,containers) `b.end() ` [30](#container.reqmts-30) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L360) *Result*: iterator;const_iterator for constant b[.](#container.reqmts-30.sentence-1) [31](#container.reqmts-31) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L365) *Returns*: An iterator which is the past-the-end value for the container[.](#container.reqmts-31.sentence-1) [32](#container.reqmts-32) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L369) *Complexity*: Constant[.](#container.reqmts-32.sentence-1) [🔗](#lib:cbegin,containers) `b.cbegin() ` [33](#container.reqmts-33) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L380) *Result*: const_iterator[.](#container.reqmts-33.sentence-1) [34](#container.reqmts-34) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L384) *Returns*: const_cast(b).begin() [35](#container.reqmts-35) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L388) *Complexity*: Constant[.](#container.reqmts-35.sentence-1) [🔗](#lib:cend,containers) `b.cend() ` [36](#container.reqmts-36) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L399) *Result*: const_iterator[.](#container.reqmts-36.sentence-1) [37](#container.reqmts-37) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L403) *Returns*: const_cast(b).end() [38](#container.reqmts-38) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L407) *Complexity*: Constant[.](#container.reqmts-38.sentence-1) [🔗](#container.reqmts-itemdecl:18) `i <=> j ` [39](#container.reqmts-39) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L417) *Result*: strong_ordering[.](#container.reqmts-39.sentence-1) [40](#container.reqmts-40) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L421) *Constraints*: X​::​iterator meets the random access iterator requirements[.](#container.reqmts-40.sentence-1) [41](#container.reqmts-41) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L425) *Complexity*: Constant[.](#container.reqmts-41.sentence-1) [🔗](#lib:operator==,containers) `c == b ` [42](#container.reqmts-42) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L454) *Preconditions*: T meets the *Cpp17EqualityComparable* requirements[.](#container.reqmts-42.sentence-1) [43](#container.reqmts-43) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L458) *Result*: bool[.](#container.reqmts-43.sentence-1) [44](#container.reqmts-44) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L462) *Returns*: equal(c.begin(), c.end(), b.begin(), b.end()) [*Note [1](#container.reqmts-note-1)*: The algorithm equal is defined in [[alg.equal]](alg.equal "26.6.13 Equal")[.](#container.reqmts-44.sentence-2) — *end note*] [45](#container.reqmts-45) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L470) *Complexity*: Constant if c.size() != b.size(), linear otherwise[.](#container.reqmts-45.sentence-1) [46](#container.reqmts-46) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L474) *Remarks*: == is an equivalence relation[.](#container.reqmts-46.sentence-1) [🔗](#lib:operator!=,containers) `c != b ` [47](#container.reqmts-47) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L503) *Effects*: Equivalent to !(c == b)[.](#container.reqmts-47.sentence-1) [🔗](#lib:swap,containers) `t.swap(s) ` [48](#container.reqmts-48) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L514) *Result*: void[.](#container.reqmts-48.sentence-1) [49](#container.reqmts-49) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L518) *Effects*: Exchanges the contents of t and s[.](#container.reqmts-49.sentence-1) [50](#container.reqmts-50) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L522) *Complexity*: Linear for array and inplace_vector, and constant for all other standard containers[.](#container.reqmts-50.sentence-1) [🔗](#container.reqmts-itemdecl:22) `swap(t, s) ` [51](#container.reqmts-51) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L533) *Effects*: Equivalent to t.swap(s)[.](#container.reqmts-51.sentence-1) [🔗](#lib:size,containers) `c.size() ` [52](#container.reqmts-52) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L544) *Result*: size_type[.](#container.reqmts-52.sentence-1) [53](#container.reqmts-53) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L548) *Returns*: distance(c.begin(), c.end()), i.e., the number of elements in the container[.](#container.reqmts-53.sentence-1) [54](#container.reqmts-54) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L553) *Complexity*: Constant[.](#container.reqmts-54.sentence-1) [55](#container.reqmts-55) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L557) *Remarks*: The number of elements is defined by the rules of constructors, inserts, and erases[.](#container.reqmts-55.sentence-1) [🔗](#lib:max_size,containers) `c.max_size() ` [56](#container.reqmts-56) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L569) *Result*: size_type[.](#container.reqmts-56.sentence-1) [57](#container.reqmts-57) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L573) *Returns*: distance(begin(), end()) for the largest possible container[.](#container.reqmts-57.sentence-1) [58](#container.reqmts-58) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L577) *Complexity*: Constant[.](#container.reqmts-58.sentence-1) [🔗](#lib:empty,containers) `c.empty() ` [59](#container.reqmts-59) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L588) *Result*: bool[.](#container.reqmts-59.sentence-1) [60](#container.reqmts-60) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L592) *Returns*: c.begin() == c.end() [61](#container.reqmts-61) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L596) *Complexity*: Constant[.](#container.reqmts-61.sentence-1) [62](#container.reqmts-62) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L600) *Remarks*: If the container is empty, then c.empty() is true[.](#container.reqmts-62.sentence-1) [63](#container.reqmts-63) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L605) In the expressionsi == j i != j i < j i <= j i >= j i > j i <=> j i - j where i and j denote objects of a container's iterator type, either or both may be replaced by an object of the container'sconst_iterator type referring to the same element with no change in semantics[.](#container.reqmts-63.sentence-1) [64](#container.reqmts-64) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L621) Unless otherwise specified, all containers defined in this Clause obtain memory using an allocator (see [[allocator.requirements]](allocator.requirements "16.4.4.6 Cpp17Allocator requirements"))[.](#container.reqmts-64.sentence-1) [*Note [2](#container.reqmts-note-2)*: In particular, containers and iterators do not store references to allocated elements other than through the allocator's pointer type, i.e., as objects of type P orpointer_traits

​::​template rebind<*unspecified*>, where P is allocator_traits​::​pointer[.](#container.reqmts-64.sentence-2) — *end note*] Copy constructors for these container types obtain an allocator by callingallocator_traits​::​select_on_container_copy_construction on the allocator belonging to the container being copied[.](#container.reqmts-64.sentence-3) Move constructors obtain an allocator by move construction from the allocator belonging to the container being moved[.](#container.reqmts-64.sentence-4) Such move construction of the allocator shall not exit via an exception[.](#container.reqmts-64.sentence-5) All other constructors for these container types take aconst allocator_type& argument[.](#container.reqmts-64.sentence-6) [*Note [3](#container.reqmts-note-3)*: If an invocation of a constructor uses the default value of an optional allocator argument, then the allocator type must support value-initialization[.](#container.reqmts-64.sentence-7) — *end note*] A copy of this allocator is used for any memory allocation and element construction performed, by these constructors and by all member functions, during the lifetime of each container object or until the allocator is replaced[.](#container.reqmts-64.sentence-8) The allocator may be replaced only via assignment orswap()[.](#container.reqmts-64.sentence-9) Allocator replacement is performed by copy assignment, move assignment, or swapping of the allocator only if - [(64.1)](#container.reqmts-64.1) allocator_traits​::​propagate_on_container_copy_assignment​::​value, - [(64.2)](#container.reqmts-64.2) allocator_traits​::​propagate_on_container_move_assignment​::​value, or - [(64.3)](#container.reqmts-64.3) allocator_traits​::​propagate_on_container_swap​::​value is true within the implementation of the corresponding container operation[.](#container.reqmts-64.sentence-10) In all container types defined in this Clause, the member get_allocator() returns a copy of the allocator used to construct the container or, if that allocator has been replaced, a copy of the most recent replacement[.](#container.reqmts-64.sentence-11) [65](#container.reqmts-65) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L661) The expression a.swap(b), for containers a and b of a standard container type other than array and inplace_vector, shall exchange the values of a andb without invoking any move, copy, or swap operations on the individual container elements[.](#container.reqmts-65.sentence-1) Any Compare, Pred, or Hash types belonging to a and b shall meet the *Cpp17Swappable* requirements and shall be exchanged by calling swap as described in [[swappable.requirements]](swappable.requirements "16.4.4.3 Swappable requirements")[.](#container.reqmts-65.sentence-2) Ifallocator_traits​::​propagate_on_container_swap​::​value istrue, thenallocator_type shall meet the *Cpp17Swappable* requirements and the allocators of a and b shall also be exchanged by calling swap as described in [[swappable.requirements]](swappable.requirements "16.4.4.3 Swappable requirements")[.](#container.reqmts-65.sentence-3) Otherwise, the allocators shall not be swapped, and the behavior is undefined unless a.get_allocator() == b.get_allocator()[.](#container.reqmts-65.sentence-4) Every iterator referring to an element in one container before the swap shall refer to the same element in the other container after the swap[.](#container.reqmts-65.sentence-5) It is unspecified whether an iterator with value a.end() before the swap will have value b.end() after the swap[.](#container.reqmts-65.sentence-6) [66](#container.reqmts-66) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L683) Unless otherwise specified (see [[associative.reqmts.except]](#associative.reqmts.except "23.2.7.2 Exception safety guarantees"), [[unord.req.except]](#unord.req.except "23.2.8.2 Exception safety guarantees"), [[deque.modifiers]](deque.modifiers "23.3.5.4 Modifiers"), [[inplace.vector.modifiers]](inplace.vector.modifiers "23.3.16.5 Modifiers"), and[[vector.modifiers]](vector.modifiers "23.3.13.5 Modifiers")) all container types defined in this Clause meet the following additional requirements: - [(66.1)](#container.reqmts-66.1) If an exception is thrown by aninsert() or emplace() function while inserting a single element, that function has no effects[.](#container.reqmts-66.1.sentence-1) - [(66.2)](#container.reqmts-66.2) If an exception is thrown by apush_back(),push_front(),emplace_back(), or emplace_front() function, that function has no effects[.](#container.reqmts-66.2.sentence-1) - [(66.3)](#container.reqmts-66.3) Noerase(),clear(),pop_back() orpop_front() function throws an exception[.](#container.reqmts-66.3.sentence-1) - [(66.4)](#container.reqmts-66.4) No copy constructor or assignment operator of a returned iterator throws an exception[.](#container.reqmts-66.4.sentence-1) - [(66.5)](#container.reqmts-66.5) Noswap() function throws an exception[.](#container.reqmts-66.5.sentence-1) - [(66.6)](#container.reqmts-66.6) Noswap() function invalidates any references, pointers, or iterators referring to the elements of the containers being swapped[.](#container.reqmts-66.6.sentence-1) [*Note [4](#container.reqmts-note-4)*: The end() iterator does not refer to any element, so it can be invalidated[.](#container.reqmts-66.6.sentence-2) — *end note*] [67](#container.reqmts-67) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L726) Unless otherwise specified (either explicitly or by defining a function in terms of other functions), invoking a container member function or passing a container as an argument to a library function shall not invalidate iterators to, or change the values of, objects within that container[.](#container.reqmts-67.sentence-1) [68](#container.reqmts-68) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L733) A [*contiguous container*](#def:container,contiguous "23.2.2.2 Container requirements [container.reqmts]") is a container whose member types iterator and const_iterator meet the*Cpp17RandomAccessIterator* requirements ([[random.access.iterators]](random.access.iterators "24.3.5.7 Random access iterators")) and model [contiguous_iterator](iterator.concept.contiguous#concept:contiguous_iterator "24.3.4.14 Concept contiguous_­iterator [iterator.concept.contiguous]") ([[iterator.concept.contiguous]](iterator.concept.contiguous "24.3.4.14 Concept contiguous_­iterator"))[.](#container.reqmts-68.sentence-1) [69](#container.reqmts-69) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L741) The behavior of certain container member functions and deduction guides depends on whether types qualify as input iterators or allocators[.](#container.reqmts-69.sentence-1) The extent to which an implementation determines that a type cannot be an input iterator is unspecified, except that as a minimum integral types shall not qualify as input iterators[.](#container.reqmts-69.sentence-2) Likewise, the extent to which an implementation determines that a type cannot be an allocator is unspecified, except that as a minimum a type A shall not qualify as an allocator unless it meets both of the following conditions: - [(69.1)](#container.reqmts-69.1) The [*qualified-id*](expr.prim.id.qual#nt:qualified-id "7.5.5.3 Qualified names [expr.prim.id.qual]") A​::​value_type is valid and denotes a type ([[temp.deduct]](temp.deduct "13.10.3 Template argument deduction"))[.](#container.reqmts-69.1.sentence-1) - [(69.2)](#container.reqmts-69.2) The expression declval().allocate(size_t{}) is well-formed when treated as an unevaluated operand[.](#container.reqmts-69.2.sentence-1) #### [23.2.2.3](#container.rev.reqmts) Reversible container requirements [[container.rev.reqmts]](container.rev.reqmts) [1](#container.rev.reqmts-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L782) A type X meets the [*reversible container*](#def:container,reversible "23.2.2.3 Reversible container requirements [container.rev.reqmts]") requirements ifX meets the container requirements, the iterator type of X belongs to the bidirectional or random access iterator categories ([[iterator.requirements]](iterator.requirements "24.3 Iterator requirements")), and the following types and expressions are well-formed and have the specified semantics[.](#container.rev.reqmts-1.sentence-1) [🔗](#lib:reverse_iterator,containers) `typename X::reverse_iterator ` [2](#container.rev.reqmts-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L797) *Result*: The type reverse_iterator, an iterator type whose value type is T[.](#container.rev.reqmts-2.sentence-1) [🔗](#lib:const_reverse_iterator,containers) `typename X::const_reverse_iterator ` [3](#container.rev.reqmts-3) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L809) *Result*: The type reverse_iterator, a constant iterator type whose value type is T[.](#container.rev.reqmts-3.sentence-1) [🔗](#lib:rbegin,containers) `a.rbegin() ` [4](#container.rev.reqmts-4) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L821) *Result*: reverse_iterator;const_reverse_iterator for constant a[.](#container.rev.reqmts-4.sentence-1) [5](#container.rev.reqmts-5) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L826) *Returns*: reverse_iterator(end()) [6](#container.rev.reqmts-6) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L830) *Complexity*: Constant[.](#container.rev.reqmts-6.sentence-1) [🔗](#lib:rend,containers) `a.rend() ` [7](#container.rev.reqmts-7) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L841) *Result*: reverse_iterator;const_reverse_iterator for constant a[.](#container.rev.reqmts-7.sentence-1) [8](#container.rev.reqmts-8) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L846) *Returns*: reverse_iterator(begin()) [9](#container.rev.reqmts-9) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L850) *Complexity*: Constant[.](#container.rev.reqmts-9.sentence-1) [🔗](#lib:crbegin,containers) `a.crbegin() ` [10](#container.rev.reqmts-10) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L861) *Result*: const_reverse_iterator[.](#container.rev.reqmts-10.sentence-1) [11](#container.rev.reqmts-11) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L865) *Returns*: const_cast(a).rbegin() [12](#container.rev.reqmts-12) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L869) *Complexity*: Constant[.](#container.rev.reqmts-12.sentence-1) [🔗](#lib:crend,containers) `a.crend() ` [13](#container.rev.reqmts-13) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L880) *Result*: const_reverse_iterator[.](#container.rev.reqmts-13.sentence-1) [14](#container.rev.reqmts-14) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L884) *Returns*: const_cast(a).rend() [15](#container.rev.reqmts-15) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L888) *Complexity*: Constant[.](#container.rev.reqmts-15.sentence-1) #### [23.2.2.4](#container.opt.reqmts) Optional container requirements [[container.opt.reqmts]](container.opt.reqmts) [1](#container.opt.reqmts-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L896) The following operations are provided for some types of containers but not others[.](#container.opt.reqmts-1.sentence-1) Those containers for which the listed operations are provided shall implement the semantics as described unless otherwise stated[.](#container.opt.reqmts-1.sentence-2) If the iterators passed to lexicographical_compare_three_way meet the constexpr iterator requirements ([[iterator.requirements.general]](iterator.requirements.general "24.3.1 General")) then the operations described below are implemented by constexpr functions[.](#container.opt.reqmts-1.sentence-3) [🔗](#lib:operator%3c=%3e,containers) `a <=> b ` [2](#container.opt.reqmts-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L931) *Result*: *synth-three-way-result*[.](#container.opt.reqmts-2.sentence-1) [3](#container.opt.reqmts-3) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L935) *Preconditions*: Either T models [three_way_comparable](cmp.concept#concept:three_way_comparable "17.12.4 Concept three_­way_­comparable [cmp.concept]"), or < is defined for values of type (possibly const) T and< is a total ordering relationship[.](#container.opt.reqmts-3.sentence-1) [4](#container.opt.reqmts-4) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L941) *Returns*: lexicographical_compare_three_way(a.begin(), a.end(), b.begin(), b.end(), *synth-three-way*) [*Note [1](#container.opt.reqmts-note-1)*: The algorithm lexicographical_compare_three_way is defined in [[algorithms]](algorithms "26 Algorithms library")[.](#container.opt.reqmts-4.sentence-1) — *end note*] [5](#container.opt.reqmts-5) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L950) *Complexity*: Linear[.](#container.opt.reqmts-5.sentence-1) #### [23.2.2.5](#container.alloc.reqmts) Allocator-aware containers [[container.alloc.reqmts]](container.alloc.reqmts) [1](#container.alloc.reqmts-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L957) Except for array and inplace_vector, all of the containers defined in [[containers]](containers "23 Containers library"),[[stacktrace.basic]](stacktrace.basic "19.6.4 Class template basic_­stacktrace"), [[basic.string]](basic.string "27.4.3 Class template basic_­string"), and [[re.results]](re.results "28.6.9 Class template match_­results") meet the additional requirements of an [*allocator-aware container*](#def:container,allocator-aware "23.2.2.5 Allocator-aware containers [container.alloc.reqmts]"), as described below[.](#container.alloc.reqmts-1.sentence-1) [2](#container.alloc.reqmts-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L964) Given an allocator type A and given a container type X having a value_type identical to T and an allocator_type identical to allocator_traits​::​rebind_alloc and given an lvalue m of type A, a pointer p of type T*, an expression v that denotes an lvalue of type T or const T or an rvalue of type const T, and an rvalue rv of type T, the following terms are defined[.](#container.alloc.reqmts-2.sentence-1) If X is not allocator-aware or is a specialization of basic_string, the terms below are defined as if A wereallocator — no allocator object needs to be created and user specializations of allocator are not instantiated: - [(2.1)](#container.alloc.reqmts-2.1) T is [**Cpp17DefaultInsertable* into X*](#def:Cpp17DefaultInsertable_into_X "23.2.2.5 Allocator-aware containers [container.alloc.reqmts]") means that the following expression is well-formed:allocator_traits::construct(m, p) - [(2.2)](#container.alloc.reqmts-2.2) An element of X is [*default-inserted*](#def:default-inserted "23.2.2.5 Allocator-aware containers [container.alloc.reqmts]") if it is initialized by evaluation of the expressionallocator_traits::construct(m, p) where p is the address of the uninitialized storage for the element allocated within X. - [(2.3)](#container.alloc.reqmts-2.3) T is [**Cpp17MoveInsertable* into X*](#def:Cpp17MoveInsertable_into_X "23.2.2.5 Allocator-aware containers [container.alloc.reqmts]") means that the following expression is well-formed:allocator_traits::construct(m, p, rv) and its evaluation causes the following postcondition to hold: The value of *p is equivalent to the value of rv before the evaluation. [*Note [1](#container.alloc.reqmts-note-1)*: rv remains a valid object[.](#container.alloc.reqmts-2.3.sentence-2) Its state is unspecified[.](#container.alloc.reqmts-2.3.sentence-3) — *end note*] - [(2.4)](#container.alloc.reqmts-2.4) T is [**Cpp17CopyInsertable* into X*](#def:Cpp17CopyInsertable_into_X "23.2.2.5 Allocator-aware containers [container.alloc.reqmts]") means that, in addition to T being *Cpp17MoveInsertable* intoX, the following expression is well-formed:allocator_traits::construct(m, p, v) and its evaluation causes the following postcondition to hold: The value of v is unchanged and is equivalent to *p. - [(2.5)](#container.alloc.reqmts-2.5) T is[**Cpp17EmplaceConstructible* into X from args*](#def:Cpp17EmplaceConstructible_into_X_from_args "23.2.2.5 Allocator-aware containers [container.alloc.reqmts]"), for zero or more arguments args, means that the following expression is well-formed:allocator_traits::construct(m, p, args) - [(2.6)](#container.alloc.reqmts-2.6) T is[**Cpp17Erasable* from X*](#def:Cpp17Erasable_from_X "23.2.2.5 Allocator-aware containers [container.alloc.reqmts]") means that the following expression is well-formed:allocator_traits::destroy(m, p) [*Note [2](#container.alloc.reqmts-note-2)*: A container calls allocator_traits​::​construct(m, p, args) to construct an element at p using args, with m == get_allocator()[.](#container.alloc.reqmts-2.sentence-3) The default construct in allocator will call ​::​new((void*)p) T(args), but specialized allocators can choose a different definition[.](#container.alloc.reqmts-2.sentence-4) — *end note*] [3](#container.alloc.reqmts-3) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1051) In this subclause, - [(3.1)](#container.alloc.reqmts-3.1) X denotes an allocator-aware container class with a value_type of T using an allocator of type A, - [(3.2)](#container.alloc.reqmts-3.2) u denotes a variable, - [(3.3)](#container.alloc.reqmts-3.3) a and b denote non-const lvalues of type X, - [(3.4)](#container.alloc.reqmts-3.4) c denotes an lvalue of type const X, - [(3.5)](#container.alloc.reqmts-3.5) t denotes an lvalue or a const rvalue of type X, - [(3.6)](#container.alloc.reqmts-3.6) rv denotes a non-const rvalue of type X, and - [(3.7)](#container.alloc.reqmts-3.7) m is a value of type A[.](#container.alloc.reqmts-3.sentence-1) A type X meets the allocator-aware container requirements if X meets the container requirements and the following types, statements, and expressions are well-formed and have the specified semantics[.](#container.alloc.reqmts-3.sentence-2) [🔗](#lib:allocator_type,containers) `typename X::allocator_type ` [4](#container.alloc.reqmts-4) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1100) *Result*: A [5](#container.alloc.reqmts-5) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1104) *Mandates*: allocator_type​::​value_type is the same as X​::​value_type[.](#container.alloc.reqmts-5.sentence-1) [🔗](#lib:get_allocator,containers) `c.get_allocator() ` [6](#container.alloc.reqmts-6) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1115) *Result*: A [7](#container.alloc.reqmts-7) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1119) *Complexity*: Constant[.](#container.alloc.reqmts-7.sentence-1) [🔗](#container.alloc.reqmts-itemdecl:3) `X u; X u = X(); ` [8](#container.alloc.reqmts-8) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1130) *Preconditions*: A meets the *Cpp17DefaultConstructible* requirements[.](#container.alloc.reqmts-8.sentence-1) [9](#container.alloc.reqmts-9) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1134) *Postconditions*: u.empty() returns true, u.get_allocator() == A()[.](#container.alloc.reqmts-9.sentence-1) [10](#container.alloc.reqmts-10) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1138) *Complexity*: Constant[.](#container.alloc.reqmts-10.sentence-1) [🔗](#container.alloc.reqmts-itemdecl:4) `X u(m); ` [11](#container.alloc.reqmts-11) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1148) *Postconditions*: u.empty() returns true, u.get_allocator() == m[.](#container.alloc.reqmts-11.sentence-1) [12](#container.alloc.reqmts-12) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1152) *Complexity*: Constant[.](#container.alloc.reqmts-12.sentence-1) [🔗](#container.alloc.reqmts-itemdecl:5) `X u(t, m); ` [13](#container.alloc.reqmts-13) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1162) *Preconditions*: T is *Cpp17CopyInsertable* into X[.](#container.alloc.reqmts-13.sentence-1) [14](#container.alloc.reqmts-14) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1166) *Postconditions*: u == t, u.get_allocator() == m[.](#container.alloc.reqmts-14.sentence-1) [15](#container.alloc.reqmts-15) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1170) *Complexity*: Linear[.](#container.alloc.reqmts-15.sentence-1) [🔗](#container.alloc.reqmts-itemdecl:6) `X u(rv); ` [16](#container.alloc.reqmts-16) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1180) *Postconditions*: u has the same elements as rv had before this construction; the value of u.get_allocator() is the same as the value of rv.get_allocator() before this construction[.](#container.alloc.reqmts-16.sentence-1) [17](#container.alloc.reqmts-17) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1186) *Complexity*: Constant[.](#container.alloc.reqmts-17.sentence-1) [🔗](#container.alloc.reqmts-itemdecl:7) `X u(rv, m); ` [18](#container.alloc.reqmts-18) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1196) *Preconditions*: T is *Cpp17MoveInsertable* into X[.](#container.alloc.reqmts-18.sentence-1) [19](#container.alloc.reqmts-19) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1200) *Postconditions*: u has the same elements, or copies of the elements, that rv had before this construction,u.get_allocator() == m[.](#container.alloc.reqmts-19.sentence-1) [20](#container.alloc.reqmts-20) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1206) *Complexity*: Constant if m == rv.get_allocator(), otherwise linear[.](#container.alloc.reqmts-20.sentence-1) [🔗](#container.alloc.reqmts-itemdecl:8) `a = t ` [21](#container.alloc.reqmts-21) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1216) *Result*: X&[.](#container.alloc.reqmts-21.sentence-1) [22](#container.alloc.reqmts-22) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1220) *Preconditions*: T is *Cpp17CopyInsertable* into X and*Cpp17CopyAssignable*[.](#container.alloc.reqmts-22.sentence-1) [23](#container.alloc.reqmts-23) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1225) *Postconditions*: a == t is true[.](#container.alloc.reqmts-23.sentence-1) [24](#container.alloc.reqmts-24) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1229) *Complexity*: Linear[.](#container.alloc.reqmts-24.sentence-1) [🔗](#lib:operator=,containers_) `a = rv ` [25](#container.alloc.reqmts-25) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1240) *Result*: X&[.](#container.alloc.reqmts-25.sentence-1) [26](#container.alloc.reqmts-26) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1244) *Preconditions*: Ifallocator_traits​::​propagate_on_container_move_assignment​::​value is false,T is *Cpp17MoveInsertable* into X and*Cpp17MoveAssignable*[.](#container.alloc.reqmts-26.sentence-1) [27](#container.alloc.reqmts-27) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1252) *Effects*: All existing elements of a are either move assigned to or destroyed[.](#container.alloc.reqmts-27.sentence-1) [28](#container.alloc.reqmts-28) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1256) *Postconditions*: If a and rv do not refer to the same object,a is equal to the value that rv had before this assignment[.](#container.alloc.reqmts-28.sentence-1) [29](#container.alloc.reqmts-29) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1261) *Complexity*: Linear[.](#container.alloc.reqmts-29.sentence-1) [🔗](#lib:swap,containers_) `a.swap(b) ` [30](#container.alloc.reqmts-30) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1272) *Result*: void [31](#container.alloc.reqmts-31) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1276) *Effects*: Exchanges the contents of a and b[.](#container.alloc.reqmts-31.sentence-1) [32](#container.alloc.reqmts-32) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1280) *Complexity*: Constant[.](#container.alloc.reqmts-32.sentence-1) ### [23.2.3](#dataraces) Container data races [[container.requirements.dataraces]](container.requirements.dataraces) [1](#dataraces-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1288) For purposes of avoiding data races ([[res.on.data.races]](res.on.data.races "16.4.6.10 Data race avoidance")), implementations shall consider the following functions to be const: begin, end,rbegin, rend, front, back, data, find,lower_bound, upper_bound, equal_range, at and, except in associative or unordered associative containers, operator[][.](#dataraces-1.sentence-1) [2](#dataraces-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1295) Notwithstanding [[res.on.data.races]](res.on.data.races "16.4.6.10 Data race avoidance"), implementations are required to avoid data races when the contents of the contained object in different elements in the same container, excepting vector, are modified concurrently[.](#dataraces-2.sentence-1) [3](#dataraces-3) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1300) [*Note [1](#dataraces-note-1)*: For a vector x with a size greater than one, x[1] = 5 and *x.begin() = 10 can be executed concurrently without a data race, butx[0] = 5 and *x.begin() = 10 executed concurrently can result in a data race[.](#dataraces-3.sentence-1) As an exception to the general rule, for a vector y, y[0] = true can race with y[1] = true[.](#dataraces-3.sentence-2) — *end note*] ### [23.2.4](#sequence.reqmts) Sequence containers [[sequence.reqmts]](sequence.reqmts) [1](#sequence.reqmts-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1312) A sequence container organizes a finite set of objects, all of the same type, into a strictly linear arrangement[.](#sequence.reqmts-1.sentence-1) The library provides the following basic kinds of sequence containers:vector, inplace_vector,forward_list, list, and deque[.](#sequence.reqmts-1.sentence-2) In addition,array and hive are provided as sequence containers which provide limited sequence operations, in array's case because it has a fixed number of elements, and in hive's case because insertion order is unspecified[.](#sequence.reqmts-1.sentence-3) The library also provides container adaptors that make it easy to construct abstract data types, such as stacks,queues,flat_maps,flat_multimaps,flat_sets, orflat_multisets, out of the basic sequence container kinds (or out of other program-defined sequence containers)[.](#sequence.reqmts-1.sentence-4) [2](#sequence.reqmts-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1332) In this subclause, - [(2.1)](#sequence.reqmts-2.1) X denotes a sequence container class, - [(2.2)](#sequence.reqmts-2.2) a denotes a value of type X containing elements of type T, - [(2.3)](#sequence.reqmts-2.3) u denotes the name of a variable being declared, - [(2.4)](#sequence.reqmts-2.4) A denotes X​::​allocator_type if the [*qualified-id*](expr.prim.id.qual#nt:qualified-id "7.5.5.3 Qualified names [expr.prim.id.qual]") X​::​allocator_type is valid and denotes a type ([[temp.deduct]](temp.deduct "13.10.3 Template argument deduction")) andallocator if it doesn't, - [(2.5)](#sequence.reqmts-2.5) i and j denote iterators that meet the *Cpp17InputIterator* requirements and refer to elements implicitly convertible to value_type, - [(2.6)](#sequence.reqmts-2.6) [i, j) denotes a valid range, - [(2.7)](#sequence.reqmts-2.7) rg denotes a value of a type R that models [*container-compatible-range*](#concept:container-compatible-range "23.2.2.1 Introduction [container.intro.reqmts]"), - [(2.8)](#sequence.reqmts-2.8) il designates an object of type initializer_list, - [(2.9)](#sequence.reqmts-2.9) n denotes a value of type X​::​size_type, - [(2.10)](#sequence.reqmts-2.10) p denotes a valid constant iterator to a, - [(2.11)](#sequence.reqmts-2.11) q denotes a valid dereferenceable constant iterator to a, - [(2.12)](#sequence.reqmts-2.12) [q1, q2) denotes a valid range of constant iterators in a, - [(2.13)](#sequence.reqmts-2.13) t denotes an lvalue or a const rvalue of X​::​value_type, and - [(2.14)](#sequence.reqmts-2.14) rv denotes a non-const rvalue of X​::​value_type[.](#sequence.reqmts-2.14.sentence-1) - [(2.15)](#sequence.reqmts-2.15) Args denotes a template parameter pack; - [(2.16)](#sequence.reqmts-2.16) args denotes a function parameter pack with the pattern Args&&[.](#sequence.reqmts-2.16.sentence-1) [3](#sequence.reqmts-3) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1375) The complexities of the expressions are sequence dependent[.](#sequence.reqmts-3.sentence-1) [4](#sequence.reqmts-4) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1387) A type X meets the [*sequence container*](#def:container,sequence "23.2.4 Sequence containers [sequence.reqmts]") requirements if X meets the container requirements and the following statements and expressions are well-formed and have the specified semantics[.](#sequence.reqmts-4.sentence-1) [🔗](#sequence.reqmts-itemdecl:1) `X u(n, t); ` [5](#sequence.reqmts-5) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1398) *Preconditions*: T is *Cpp17CopyInsertable* into X[.](#sequence.reqmts-5.sentence-1) [6](#sequence.reqmts-6) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1402) *Effects*: Constructs a sequence container with n copies of t[.](#sequence.reqmts-6.sentence-1) [7](#sequence.reqmts-7) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1406) *Postconditions*: distance(u.begin(), u.end()) == n is true[.](#sequence.reqmts-7.sentence-1) [🔗](#sequence.reqmts-itemdecl:2) `X u(i, j); ` [8](#sequence.reqmts-8) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1416) *Preconditions*: T is *Cpp17EmplaceConstructible* into X from *i[.](#sequence.reqmts-8.sentence-1) For vector, if the iterator does not meet the *Cpp17ForwardIterator* requirements ([[forward.iterators]](forward.iterators "24.3.5.5 Forward iterators")),T is also *Cpp17MoveInsertable* into X[.](#sequence.reqmts-8.sentence-2) [9](#sequence.reqmts-9) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1424) *Effects*: Constructs a sequence container equal to the range [i, j)[.](#sequence.reqmts-9.sentence-1) Each iterator in the range [i, j) is dereferenced exactly once[.](#sequence.reqmts-9.sentence-2) [10](#sequence.reqmts-10) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1429) *Postconditions*: distance(u.begin(), u.end()) == distance(i, j) is true[.](#sequence.reqmts-10.sentence-1) [🔗](#sequence.reqmts-itemdecl:3) `X(from_range, rg) ` [11](#sequence.reqmts-11) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1439) *Preconditions*: T is *Cpp17EmplaceConstructible* into X from *ranges​::​begin(rg)[.](#sequence.reqmts-11.sentence-1) For vector, if R modelsranges​::​[approximately_sized_range](range.approximately.sized#concept:approximately_sized_range "25.4.3 Approximately sized ranges [range.approximately.sized]") but not ranges​::​[sized_range](range.sized#concept:sized_range "25.4.4 Sized ranges [range.sized]") or modelsranges​::​[input_range](range.refinements#concept:input_range "25.4.6 Other range refinements [range.refinements]") but not ranges​::​[forward_range](range.refinements#concept:forward_range "25.4.6 Other range refinements [range.refinements]"),T is also *Cpp17MoveInsertable* into X[.](#sequence.reqmts-11.sentence-2) [12](#sequence.reqmts-12) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1451) *Effects*: Constructs a sequence container equal to the range rg[.](#sequence.reqmts-12.sentence-1) Each iterator in the range rg is dereferenced exactly once[.](#sequence.reqmts-12.sentence-2) [13](#sequence.reqmts-13) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1456) *Recommended practice*: If R models ranges​::​[approximately_sized_range](range.approximately.sized#concept:approximately_sized_range "25.4.3 Approximately sized ranges [range.approximately.sized]") andranges​::​distance(rg) <= ranges​::​reserve_hint(rg) is true, an implementation should not perform more than a single reallocation[.](#sequence.reqmts-13.sentence-1) [14](#sequence.reqmts-14) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1462) *Postconditions*: distance(begin(), end()) == ranges​::​distance(rg) is true[.](#sequence.reqmts-14.sentence-1) [🔗](#sequence.reqmts-itemdecl:4) `X(il) ` [15](#sequence.reqmts-15) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1472) *Effects*: Equivalent to X(il.begin(), il.end())[.](#sequence.reqmts-15.sentence-1) [🔗](#sequence.reqmts-itemdecl:5) `a = il ` [16](#sequence.reqmts-16) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1482) *Result*: X&[.](#sequence.reqmts-16.sentence-1) [17](#sequence.reqmts-17) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1486) *Preconditions*: T is *Cpp17CopyInsertable* into X and*Cpp17CopyAssignable*[.](#sequence.reqmts-17.sentence-1) [18](#sequence.reqmts-18) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1491) *Effects*: Assigns the range [il.begin(), il.end()) into a[.](#sequence.reqmts-18.sentence-1) All existing elements of a are either assigned to or destroyed[.](#sequence.reqmts-18.sentence-2) [19](#sequence.reqmts-19) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1496) *Returns*: *this[.](#sequence.reqmts-19.sentence-1) [🔗](#lib:emplace,containers) `a.emplace(p, args) ` [20](#sequence.reqmts-20) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1507) *Result*: iterator[.](#sequence.reqmts-20.sentence-1) [21](#sequence.reqmts-21) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1511) *Preconditions*: T is *Cpp17EmplaceConstructible* into X from args[.](#sequence.reqmts-21.sentence-1) For vector, inplace_vector, and deque,T is also *Cpp17MoveInsertable* into X and*Cpp17MoveAssignable*[.](#sequence.reqmts-21.sentence-2) [22](#sequence.reqmts-22) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1518) *Effects*: Inserts an object of type T constructed with std​::​forward(args)... before p[.](#sequence.reqmts-22.sentence-1) [*Note [1](#sequence.reqmts-note-1)*: args can directly or indirectly refer to a value in a[.](#sequence.reqmts-22.sentence-2) — *end note*] [23](#sequence.reqmts-23) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1527) *Returns*: An iterator that points to the new element[.](#sequence.reqmts-23.sentence-1) [🔗](#lib:insert,containers) `a.insert(p, t) ` [24](#sequence.reqmts-24) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1538) *Result*: iterator[.](#sequence.reqmts-24.sentence-1) [25](#sequence.reqmts-25) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1542) *Preconditions*: T is *Cpp17CopyInsertable* into X[.](#sequence.reqmts-25.sentence-1) For vector, inplace_vector, and deque,T is also *Cpp17CopyAssignable*[.](#sequence.reqmts-25.sentence-2) [26](#sequence.reqmts-26) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1548) *Effects*: Inserts a copy of t before p[.](#sequence.reqmts-26.sentence-1) [27](#sequence.reqmts-27) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1552) *Returns*: An iterator that points to the copy of t inserted into a[.](#sequence.reqmts-27.sentence-1) [🔗](#sequence.reqmts-itemdecl:8) `a.insert(p, rv) ` [28](#sequence.reqmts-28) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1562) *Result*: iterator[.](#sequence.reqmts-28.sentence-1) [29](#sequence.reqmts-29) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1566) *Preconditions*: T is *Cpp17MoveInsertable* into X[.](#sequence.reqmts-29.sentence-1) For vector, inplace_vector, and deque,T is also *Cpp17MoveAssignable*[.](#sequence.reqmts-29.sentence-2) [30](#sequence.reqmts-30) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1572) *Effects*: Inserts a copy of rv before p[.](#sequence.reqmts-30.sentence-1) [31](#sequence.reqmts-31) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1576) *Returns*: An iterator that points to the copy of rv inserted into a[.](#sequence.reqmts-31.sentence-1) [🔗](#sequence.reqmts-itemdecl:9) `a.insert(p, n, t) ` [32](#sequence.reqmts-32) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1586) *Result*: iterator[.](#sequence.reqmts-32.sentence-1) [33](#sequence.reqmts-33) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1590) *Preconditions*: T is *Cpp17CopyInsertable* into X and *Cpp17CopyAssignable*[.](#sequence.reqmts-33.sentence-1) [34](#sequence.reqmts-34) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1595) *Effects*: Inserts n copies of t before p[.](#sequence.reqmts-34.sentence-1) [35](#sequence.reqmts-35) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1599) *Returns*: An iterator that points to the copy of the first element inserted into a, orp if n == 0[.](#sequence.reqmts-35.sentence-1) [🔗](#sequence.reqmts-itemdecl:10) `a.insert(p, i, j) ` [36](#sequence.reqmts-36) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1611) *Result*: iterator[.](#sequence.reqmts-36.sentence-1) [37](#sequence.reqmts-37) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1615) *Preconditions*: T is *Cpp17EmplaceConstructible* into X from *i[.](#sequence.reqmts-37.sentence-1) For vector, inplace_vector, and deque,T is also*Cpp17MoveInsertable* into X, and T meets the*Cpp17MoveConstructible*,*Cpp17MoveAssignable*, and*Cpp17Swappable* ([[swappable.requirements]](swappable.requirements "16.4.4.3 Swappable requirements")) requirements[.](#sequence.reqmts-37.sentence-2) Neither i nor j are iterators into a[.](#sequence.reqmts-37.sentence-3) [38](#sequence.reqmts-38) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1627) *Effects*: Inserts copies of elements in [i, j) before p[.](#sequence.reqmts-38.sentence-1) Each iterator in the range [i, j) shall be dereferenced exactly once[.](#sequence.reqmts-38.sentence-2) [39](#sequence.reqmts-39) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1632) *Returns*: An iterator that points to the copy of the first element inserted into a, orp if i == j[.](#sequence.reqmts-39.sentence-1) [🔗](#lib:insert_range,containers) `a.insert_range(p, rg) ` [40](#sequence.reqmts-40) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1645) *Result*: iterator[.](#sequence.reqmts-40.sentence-1) [41](#sequence.reqmts-41) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1649) *Preconditions*: T is *Cpp17EmplaceConstructible* into X from *ranges​::​begin(rg)[.](#sequence.reqmts-41.sentence-1) For vector, inplace_vector, and deque,T is also*Cpp17MoveInsertable* into X, and T meets the*Cpp17MoveConstructible*,*Cpp17MoveAssignable*, and*Cpp17Swappable* ([[swappable.requirements]](swappable.requirements "16.4.4.3 Swappable requirements")) requirements[.](#sequence.reqmts-41.sentence-2) rg and a do not overlap[.](#sequence.reqmts-41.sentence-3) [42](#sequence.reqmts-42) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1662) *Effects*: Inserts copies of elements in rg before p[.](#sequence.reqmts-42.sentence-1) Each iterator in the range rg is dereferenced exactly once[.](#sequence.reqmts-42.sentence-2) [43](#sequence.reqmts-43) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1667) *Returns*: An iterator that points to the copy of the first element inserted into a, orp if rg is empty[.](#sequence.reqmts-43.sentence-1) [🔗](#sequence.reqmts-itemdecl:12) `a.insert(p, il) ` [44](#sequence.reqmts-44) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1679) *Effects*: Equivalent to a.insert(p, il.begin(), il.end())[.](#sequence.reqmts-44.sentence-1) [🔗](#lib:erase,containers) `a.erase(q) ` [45](#sequence.reqmts-45) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1690) *Result*: iterator[.](#sequence.reqmts-45.sentence-1) [46](#sequence.reqmts-46) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1694) *Preconditions*: For vector, inplace_vector, and deque,T is *Cpp17MoveAssignable*[.](#sequence.reqmts-46.sentence-1) [47](#sequence.reqmts-47) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1699) *Effects*: Erases the element pointed to by q[.](#sequence.reqmts-47.sentence-1) [48](#sequence.reqmts-48) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1703) *Returns*: An iterator that points to the element immediately following q prior to the element being erased[.](#sequence.reqmts-48.sentence-1) If no such element exists, a.end() is returned[.](#sequence.reqmts-48.sentence-2) [🔗](#sequence.reqmts-itemdecl:14) `a.erase(q1, q2) ` [49](#sequence.reqmts-49) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1715) *Result*: iterator[.](#sequence.reqmts-49.sentence-1) [50](#sequence.reqmts-50) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1719) *Preconditions*: For vector, inplace_vector, and deque,T is *Cpp17MoveAssignable*[.](#sequence.reqmts-50.sentence-1) [51](#sequence.reqmts-51) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1724) *Effects*: Erases the elements in the range [q1, q2)[.](#sequence.reqmts-51.sentence-1) [52](#sequence.reqmts-52) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1728) *Returns*: An iterator that points to the element pointed to by q2 prior to any elements being erased[.](#sequence.reqmts-52.sentence-1) If no such element exists, a.end() is returned[.](#sequence.reqmts-52.sentence-2) [🔗](#lib:clear,containers) `a.clear() ` [53](#sequence.reqmts-53) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1741) *Result*: void [54](#sequence.reqmts-54) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1745) *Effects*: Destroys all elements in a[.](#sequence.reqmts-54.sentence-1) Invalidates all references, pointers, and iterators referring to the elements of a and may invalidate the past-the-end iterator[.](#sequence.reqmts-54.sentence-2) [55](#sequence.reqmts-55) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1752) *Postconditions*: a.empty() is true[.](#sequence.reqmts-55.sentence-1) [56](#sequence.reqmts-56) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1756) *Complexity*: Linear[.](#sequence.reqmts-56.sentence-1) [🔗](#lib:assign,containers) `a.assign(i, j) ` [57](#sequence.reqmts-57) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1767) *Result*: void [58](#sequence.reqmts-58) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1771) *Preconditions*: T is *Cpp17EmplaceConstructible* into X from *i and assignable from *i[.](#sequence.reqmts-58.sentence-1) For vector, if the iterator does not meet the forward iterator requirements ([[forward.iterators]](forward.iterators "24.3.5.5 Forward iterators")),T is also *Cpp17MoveInsertable* into X[.](#sequence.reqmts-58.sentence-2) Neither i nor j are iterators into a[.](#sequence.reqmts-58.sentence-3) [59](#sequence.reqmts-59) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1781) *Effects*: Replaces elements in a with a copy of [i, j)[.](#sequence.reqmts-59.sentence-1) Invalidates all references, pointers and iterators referring to the elements of a[.](#sequence.reqmts-59.sentence-2) For vector and deque, also invalidates the past-the-end iterator[.](#sequence.reqmts-59.sentence-3) Each iterator in the range [i, j) is dereferenced exactly once[.](#sequence.reqmts-59.sentence-4) [🔗](#lib:assign_range,containers) `a.assign_range(rg) ` [60](#sequence.reqmts-60) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1797) *Result*: void [61](#sequence.reqmts-61) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1801) *Mandates*: [assignable_from](concept.assignable#concept:assignable_from "18.4.8 Concept assignable_­from [concept.assignable]")> is modeled[.](#sequence.reqmts-61.sentence-1) [62](#sequence.reqmts-62) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1806) *Preconditions*: T is *Cpp17EmplaceConstructible* into X from *ranges​::​begin(rg)[.](#sequence.reqmts-62.sentence-1) For vector, if R modelsranges​::​[approximately_sized_range](range.approximately.sized#concept:approximately_sized_range "25.4.3 Approximately sized ranges [range.approximately.sized]") but not ranges​::​[sized_range](range.sized#concept:sized_range "25.4.4 Sized ranges [range.sized]") or modelsranges​::​[input_range](range.refinements#concept:input_range "25.4.6 Other range refinements [range.refinements]") but not ranges​::​[forward_range](range.refinements#concept:forward_range "25.4.6 Other range refinements [range.refinements]"),T is also *Cpp17MoveInsertable* into X[.](#sequence.reqmts-62.sentence-2) rg and a do not overlap[.](#sequence.reqmts-62.sentence-3) [63](#sequence.reqmts-63) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1819) *Effects*: Replaces elements in a with a copy of each element in rg[.](#sequence.reqmts-63.sentence-1) Invalidates all references, pointers, and iterators referring to the elements of a[.](#sequence.reqmts-63.sentence-2) For vector and deque, also invalidates the past-the-end iterator[.](#sequence.reqmts-63.sentence-3) Each iterator in the range rg is dereferenced exactly once[.](#sequence.reqmts-63.sentence-4) [64](#sequence.reqmts-64) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1828) *Recommended practice*: If R models ranges​::​[approximately_sized_range](range.approximately.sized#concept:approximately_sized_range "25.4.3 Approximately sized ranges [range.approximately.sized]") andranges​::​distance(rg) <= ranges​::​reserve_hint(rg) is true, an implementation should not perform any reallocation[.](#sequence.reqmts-64.sentence-1) [🔗](#sequence.reqmts-itemdecl:18) `a.assign(il) ` [65](#sequence.reqmts-65) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1840) *Effects*: Equivalent to a.assign(il.begin(), il.end())[.](#sequence.reqmts-65.sentence-1) [🔗](#sequence.reqmts-itemdecl:19) `a.assign(n, t) ` [66](#sequence.reqmts-66) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1850) *Result*: void [67](#sequence.reqmts-67) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1854) *Preconditions*: T is *Cpp17CopyInsertable* into X and *Cpp17CopyAssignable*[.](#sequence.reqmts-67.sentence-1) t is not a reference into a[.](#sequence.reqmts-67.sentence-2) [68](#sequence.reqmts-68) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1860) *Effects*: Replaces elements in a with n copies of t[.](#sequence.reqmts-68.sentence-1) Invalidates all references, pointers and iterators referring to the elements of a[.](#sequence.reqmts-68.sentence-2) For vector and deque, also invalidates the past-the-end iterator[.](#sequence.reqmts-68.sentence-3) [69](#sequence.reqmts-69) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1869) For every sequence container defined in this Clause and in [[strings]](strings "27 Strings library"): - [(69.1)](#sequence.reqmts-69.1) If the constructortemplate X(InputIterator first, InputIterator last, const allocator_type& alloc = allocator_type()); is called with a type InputIterator that does not qualify as an input iterator, then the constructor shall not participate in overload resolution. - [(69.2)](#sequence.reqmts-69.2) If the member functions of the forms:template*return-type* *F*(const_iterator p, InputIterator first, InputIterator last); // such as inserttemplate*return-type* *F*(InputIterator first, InputIterator last); // such as append, assigntemplate*return-type* *F*(const_iterator i1, const_iterator i2, InputIterator first, InputIterator last); // such as replace are called with a type InputIterator that does not qualify as an input iterator, then these functions shall not participate in overload resolution. - [(69.3)](#sequence.reqmts-69.3) A deduction guide for a sequence container shall not participate in overload resolution if it has an InputIterator template parameter and a type that does not qualify as an input iterator is deduced for that parameter, or if it has an Allocator template parameter and a type that does not qualify as an allocator is deduced for that parameter. [70](#sequence.reqmts-70) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1906) The following operations are provided for some types of sequence containers but not others[.](#sequence.reqmts-70.sentence-1) Operations other than prepend_range and append_range are implemented so as to take amortized constant time[.](#sequence.reqmts-70.sentence-2) [🔗](#sequence.reqmts-itemdecl:20) `a.front() ` [71](#sequence.reqmts-71) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1917) *Result*: reference; const_reference for constant a[.](#sequence.reqmts-71.sentence-1) [72](#sequence.reqmts-72) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1921) *Hardened preconditions*: a.empty() is false[.](#sequence.reqmts-72.sentence-1) [73](#sequence.reqmts-73) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1925) *Returns*: *a.begin() [74](#sequence.reqmts-74) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1929) *Remarks*: Required forbasic_string,array,deque,forward_list,inplace_vector,list, andvector[.](#sequence.reqmts-74.sentence-1) [🔗](#sequence.reqmts-itemdecl:21) `a.back() ` [75](#sequence.reqmts-75) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1946) *Result*: reference; const_reference for constant a[.](#sequence.reqmts-75.sentence-1) [76](#sequence.reqmts-76) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1950) *Hardened preconditions*: a.empty() is false[.](#sequence.reqmts-76.sentence-1) [77](#sequence.reqmts-77) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1954) *Effects*: Equivalent to:auto tmp = a.end();--tmp;return *tmp; [78](#sequence.reqmts-78) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1963) *Remarks*: Required forbasic_string,array,deque,inplace_vector,list, andvector[.](#sequence.reqmts-78.sentence-1) [🔗](#sequence.reqmts-itemdecl:22) `a.emplace_front(args) ` [79](#sequence.reqmts-79) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1979) *Result*: reference [80](#sequence.reqmts-80) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1983) *Preconditions*: T is *Cpp17EmplaceConstructible* into X from args[.](#sequence.reqmts-80.sentence-1) [81](#sequence.reqmts-81) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1987) *Effects*: Prepends an object of type T constructed with std​::​forward(args)...[.](#sequence.reqmts-81.sentence-1) [82](#sequence.reqmts-82) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1992) *Returns*: a.front()[.](#sequence.reqmts-82.sentence-1) [83](#sequence.reqmts-83) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1996) *Remarks*: Required fordeque,forward_list, andlist[.](#sequence.reqmts-83.sentence-1) [🔗](#sequence.reqmts-itemdecl:23) `a.emplace_back(args) ` [84](#sequence.reqmts-84) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2009) *Result*: reference [85](#sequence.reqmts-85) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2013) *Preconditions*: T is *Cpp17EmplaceConstructible* into X from args[.](#sequence.reqmts-85.sentence-1) For vector,T is also *Cpp17MoveInsertable* into X[.](#sequence.reqmts-85.sentence-2) [86](#sequence.reqmts-86) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2019) *Effects*: Appends an object of type T constructed with std​::​forward(args)...[.](#sequence.reqmts-86.sentence-1) [87](#sequence.reqmts-87) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2024) *Returns*: a.back()[.](#sequence.reqmts-87.sentence-1) [88](#sequence.reqmts-88) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2028) *Remarks*: Required fordeque,inplace_vector,list, andvector[.](#sequence.reqmts-88.sentence-1) [🔗](#sequence.reqmts-itemdecl:24) `a.push_front(t) ` [89](#sequence.reqmts-89) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2042) *Result*: void [90](#sequence.reqmts-90) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2046) *Preconditions*: T is *Cpp17CopyInsertable* into X[.](#sequence.reqmts-90.sentence-1) [91](#sequence.reqmts-91) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2050) *Effects*: Prepends a copy of t[.](#sequence.reqmts-91.sentence-1) [92](#sequence.reqmts-92) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2054) *Remarks*: Required fordeque,forward_list, andlist[.](#sequence.reqmts-92.sentence-1) [🔗](#sequence.reqmts-itemdecl:25) `a.push_front(rv) ` [93](#sequence.reqmts-93) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2067) *Result*: void [94](#sequence.reqmts-94) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2071) *Preconditions*: T is *Cpp17MoveInsertable* into X[.](#sequence.reqmts-94.sentence-1) [95](#sequence.reqmts-95) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2075) *Effects*: Prepends a copy of rv[.](#sequence.reqmts-95.sentence-1) [96](#sequence.reqmts-96) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2079) *Remarks*: Required fordeque,forward_list, andlist[.](#sequence.reqmts-96.sentence-1) [🔗](#sequence.reqmts-itemdecl:26) `a.prepend_range(rg) ` [97](#sequence.reqmts-97) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2092) *Result*: void [98](#sequence.reqmts-98) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2096) *Preconditions*: T is *Cpp17EmplaceConstructible* into X from *ranges​::​begin(rg)[.](#sequence.reqmts-98.sentence-1) For deque,T is also *Cpp17MoveInsertable* into X, andT meets the*Cpp17MoveConstructible*,*Cpp17MoveAssignable*, and*Cpp17Swappable* ([[swappable.requirements]](swappable.requirements "16.4.4.3 Swappable requirements")) requirements[.](#sequence.reqmts-98.sentence-2) [99](#sequence.reqmts-99) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2107) *Effects*: Inserts copies of elements in rg before begin()[.](#sequence.reqmts-99.sentence-1) Each iterator in the range rg is dereferenced exactly once[.](#sequence.reqmts-99.sentence-2) [*Note [2](#sequence.reqmts-note-2)*: The order of elements in rg is not reversed[.](#sequence.reqmts-99.sentence-3) — *end note*] [100](#sequence.reqmts-100) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2115) *Remarks*: Required fordeque,forward_list, andlist[.](#sequence.reqmts-100.sentence-1) [🔗](#sequence.reqmts-itemdecl:27) `a.push_back(t) ` [101](#sequence.reqmts-101) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2128) *Result*: void [102](#sequence.reqmts-102) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2132) *Preconditions*: T is *Cpp17CopyInsertable* into X[.](#sequence.reqmts-102.sentence-1) [103](#sequence.reqmts-103) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2136) *Effects*: Appends a copy of t[.](#sequence.reqmts-103.sentence-1) [104](#sequence.reqmts-104) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2140) *Remarks*: Required forbasic_string,deque,inplace_vector,list, andvector[.](#sequence.reqmts-104.sentence-1) [🔗](#sequence.reqmts-itemdecl:28) `a.push_back(rv) ` [105](#sequence.reqmts-105) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2155) *Result*: void [106](#sequence.reqmts-106) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2159) *Preconditions*: T is *Cpp17MoveInsertable* into X[.](#sequence.reqmts-106.sentence-1) [107](#sequence.reqmts-107) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2163) *Effects*: Appends a copy of rv[.](#sequence.reqmts-107.sentence-1) [108](#sequence.reqmts-108) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2167) *Remarks*: Required forbasic_string,deque,inplace_vector,list, andvector[.](#sequence.reqmts-108.sentence-1) [🔗](#sequence.reqmts-itemdecl:29) `a.append_range(rg) ` [109](#sequence.reqmts-109) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2182) *Result*: void [110](#sequence.reqmts-110) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2186) *Preconditions*: T is *Cpp17EmplaceConstructible* into X from *ranges​::​begin(rg)[.](#sequence.reqmts-110.sentence-1) For vector,T is also*Cpp17MoveInsertable* into X[.](#sequence.reqmts-110.sentence-2) [111](#sequence.reqmts-111) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2194) *Effects*: Inserts copies of elements in rg before end()[.](#sequence.reqmts-111.sentence-1) Each iterator in the range rg is dereferenced exactly once[.](#sequence.reqmts-111.sentence-2) [112](#sequence.reqmts-112) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2199) *Remarks*: Required fordeque,inplace_vector,list, andvector[.](#sequence.reqmts-112.sentence-1) [🔗](#sequence.reqmts-itemdecl:30) `a.pop_front() ` [113](#sequence.reqmts-113) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2213) *Result*: void [114](#sequence.reqmts-114) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2217) *Hardened preconditions*: a.empty() is false[.](#sequence.reqmts-114.sentence-1) [115](#sequence.reqmts-115) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2221) *Effects*: Destroys the first element[.](#sequence.reqmts-115.sentence-1) [116](#sequence.reqmts-116) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2225) *Remarks*: Required fordeque,forward_list, andlist[.](#sequence.reqmts-116.sentence-1) [🔗](#sequence.reqmts-itemdecl:31) `a.pop_back() ` [117](#sequence.reqmts-117) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2238) *Result*: void [118](#sequence.reqmts-118) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2242) *Hardened preconditions*: a.empty() is false[.](#sequence.reqmts-118.sentence-1) [119](#sequence.reqmts-119) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2246) *Effects*: Destroys the last element[.](#sequence.reqmts-119.sentence-1) [120](#sequence.reqmts-120) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2250) *Remarks*: Required forbasic_string,deque,inplace_vector,list, andvector[.](#sequence.reqmts-120.sentence-1) [🔗](#sequence.reqmts-itemdecl:32) `a[n] ` [121](#sequence.reqmts-121) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2265) *Result*: reference; const_reference for constant a[.](#sequence.reqmts-121.sentence-1) [122](#sequence.reqmts-122) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2269) *Hardened preconditions*: n < a.size() is true[.](#sequence.reqmts-122.sentence-1) [123](#sequence.reqmts-123) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2273) *Effects*: Equivalent to: return *(a.begin() + n); [124](#sequence.reqmts-124) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2277) *Remarks*: Required forbasic_string,array,deque,inplace_vector, andvector[.](#sequence.reqmts-124.sentence-1) [🔗](#sequence.reqmts-itemdecl:33) `a.at(n) ` [125](#sequence.reqmts-125) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2292) *Result*: reference; const_reference for constant a[.](#sequence.reqmts-125.sentence-1) [126](#sequence.reqmts-126) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2296) *Returns*: *(a.begin() + n) [127](#sequence.reqmts-127) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2300) *Throws*: out_of_range if n >= a.size()[.](#sequence.reqmts-127.sentence-1) [128](#sequence.reqmts-128) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2304) *Remarks*: Required forbasic_string,array,deque,inplace_vector, andvector[.](#sequence.reqmts-128.sentence-1) ### [23.2.5](#container.node) Node handles [[container.node]](container.node) #### [23.2.5.1](#container.node.overview) Overview [[container.node.overview]](container.node.overview) [1](#container.node.overview-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2318) A [*node handle*](#def:node_handle "23.2.5.1 Overview [container.node.overview]") is an object that accepts ownership of a single element from an associative container ([[associative.reqmts]](#associative.reqmts "23.2.7 Associative containers")) or an unordered associative container ([[unord.req]](#unord.req "23.2.8 Unordered associative containers"))[.](#container.node.overview-1.sentence-1) It may be used to transfer that ownership to another container with compatible nodes[.](#container.node.overview-1.sentence-2) Containers with compatible nodes have the same node handle type[.](#container.node.overview-1.sentence-3) Elements may be transferred in either direction between container types in the same row of Table [75](#tab:container.node.compat "Table 75: Container types with compatible nodes")[.](#container.node.overview-1.sentence-4) Table [75](#tab:container.node.compat) — Container types with compatible nodes [[tab:container.node.compat]](./tab:container.node.compat) | [🔗](#tab:container.node.compat-row-1)
map | map | | --- | --- | | [🔗](#tab:container.node.compat-row-2)
map | multimap | | [🔗](#tab:container.node.compat-row-3)
set | set | | [🔗](#tab:container.node.compat-row-4)
set | multiset | | [🔗](#tab:container.node.compat-row-5)
unordered_map | unordered_map | | [🔗](#tab:container.node.compat-row-6)
unordered_map | unordered_multimap | | [🔗](#tab:container.node.compat-row-7)
unordered_set | unordered_set | | [🔗](#tab:container.node.compat-row-8)
unordered_set | unordered_multiset | [2](#container.node.overview-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2347) If a node handle is not empty, then it contains an allocator that is equal to the allocator of the container when the element was extracted[.](#container.node.overview-2.sentence-1) If a node handle is empty, it contains no allocator[.](#container.node.overview-2.sentence-2) [3](#container.node.overview-3) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2352) Class *node-handle* is for exposition only[.](#container.node.overview-3.sentence-1) [4](#container.node.overview-4) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2355) If a user-defined specialization of pair exists forpair or pair, where Key is the container's key_type and T is the container'smapped_type, the behavior of operations involving node handles is undefined[.](#container.node.overview-4.sentence-1) template<*unspecified*>class *node-handle* {public:// These type declarations are described in [[associative.reqmts]](#associative.reqmts "23.2.7 Associative containers") and [[unord.req]](#unord.req "23.2.8 Unordered associative containers").using value_type = *see below*; // not present for map containersusing key_type = *see below*; // not present for set containersusing mapped_type = *see below*; // not present for set containersusing allocator_type = *see below*; private:using container_node_type = *unspecified*; // *exposition only*using ator_traits = allocator_traits; // *exposition only*typename ator_traits::template rebind_traits::pointer ptr_; // *exposition only* optional alloc_; // *exposition only*public:// [[container.node.cons]](#container.node.cons "23.2.5.2 Constructors, copy, and assignment"), constructors, copy, and assignmentconstexpr *node-handle*() noexcept : ptr_(), alloc_() {}constexpr *node-handle*(*node-handle*&&) noexcept; constexpr *node-handle*& operator=(*node-handle*&&); // [[container.node.dtor]](#container.node.dtor "23.2.5.3 Destructor"), destructorconstexpr ~*node-handle*(); // [[container.node.observers]](#container.node.observers "23.2.5.4 Observers"), observersconstexpr value_type& value() const; // not present for map containers key_type& key() const; // not present for set containersconstexpr mapped_type& mapped() const; // not present for set containersconstexpr allocator_type get_allocator() const; constexpr explicit operator bool() const noexcept; constexpr bool empty() const noexcept; // [[container.node.modifiers]](#container.node.modifiers "23.2.5.5 Modifiers"), modifiersconstexpr void swap(*node-handle*&)noexcept(ator_traits::propagate_on_container_swap::value || ator_traits::is_always_equal::value); friend constexpr void swap(*node-handle*& x, *node-handle*& y) noexcept(noexcept(x.swap(y))) { x.swap(y); }}; #### [23.2.5.2](#container.node.cons) Constructors, copy, and assignment [[container.node.cons]](container.node.cons) [🔗](#container.node.cons-itemdecl:1) `constexpr node-handle(node-handle&& nh) noexcept; ` [1](#container.node.cons-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2416) *Effects*: Constructs a *node-handle* object initializingptr_ with nh.ptr_[.](#container.node.cons-1.sentence-1) Move constructs alloc_ withnh.alloc_[.](#container.node.cons-1.sentence-2) Assigns nullptr to nh.ptr_ and assignsnullopt to nh.alloc_[.](#container.node.cons-1.sentence-3) [🔗](#container.node.cons-itemdecl:2) `constexpr node-handle& operator=(node-handle&& nh); ` [2](#container.node.cons-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2429) *Preconditions*: Either !alloc_, orator_traits​::​propagate_on_container_move_assignment​::​value is true, or alloc_ == nh.alloc_[.](#container.node.cons-2.sentence-1) [3](#container.node.cons-3) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2435) *Effects*: - [(3.1)](#container.node.cons-3.1) If ptr_ != nullptr, destroys the value_type subobject in the container_node_type object pointed to by ptr_ by calling ator_traits​::​destroy, then deallocates ptr_ by calling ator_traits​::​template rebind_traits​::​deallocate[.](#container.node.cons-3.1.sentence-1) - [(3.2)](#container.node.cons-3.2) Assigns nh.ptr_ to ptr_[.](#container.node.cons-3.2.sentence-1) - [(3.3)](#container.node.cons-3.3) If !alloc_ or ator_traits​::​propagate_on_container_move_assignment​::​value is true, move assigns nh.alloc_ to alloc_[.](#container.node.cons-3.3.sentence-1) - [(3.4)](#container.node.cons-3.4) Assignsnullptr to nh.ptr_ and assigns nullopt tonh.alloc_[.](#container.node.cons-3.4.sentence-1) [4](#container.node.cons-4) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2454) *Returns*: *this[.](#container.node.cons-4.sentence-1) [5](#container.node.cons-5) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2458) *Throws*: Nothing[.](#container.node.cons-5.sentence-1) #### [23.2.5.3](#container.node.dtor) Destructor [[container.node.dtor]](container.node.dtor) [🔗](#container.node.dtor-itemdecl:1) `constexpr ~node-handle(); ` [1](#container.node.dtor-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2470) *Effects*: If ptr_ != nullptr, destroys the value_type subobject in the container_node_type object pointed to by ptr_ by callingator_traits​::​destroy, then deallocates ptr_ by callingator_traits​::​template rebind_traits​::​deallocate[.](#container.node.dtor-1.sentence-1) #### [23.2.5.4](#container.node.observers) Observers [[container.node.observers]](container.node.observers) [🔗](#container.node.observers-itemdecl:1) `constexpr value_type& value() const; ` [1](#container.node.observers-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2485) *Preconditions*: empty() == false[.](#container.node.observers-1.sentence-1) [2](#container.node.observers-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2489) *Returns*: A reference to the value_type subobject in thecontainer_node_type object pointed to by ptr_[.](#container.node.observers-2.sentence-1) [3](#container.node.observers-3) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2494) *Throws*: Nothing[.](#container.node.observers-3.sentence-1) [🔗](#container.node.observers-itemdecl:2) `key_type& key() const; ` [4](#container.node.observers-4) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2504) *Preconditions*: empty() == false[.](#container.node.observers-4.sentence-1) [5](#container.node.observers-5) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2508) *Returns*: A non-const reference to the key_type member of thevalue_type subobject in the container_node_type object pointed to by ptr_[.](#container.node.observers-5.sentence-1) [6](#container.node.observers-6) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2514) *Throws*: Nothing[.](#container.node.observers-6.sentence-1) [7](#container.node.observers-7) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2518) *Remarks*: Modifying the key through the returned reference is permitted[.](#container.node.observers-7.sentence-1) [🔗](#container.node.observers-itemdecl:3) `constexpr mapped_type& mapped() const; ` [8](#container.node.observers-8) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2528) *Preconditions*: empty() == false[.](#container.node.observers-8.sentence-1) [9](#container.node.observers-9) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2532) *Returns*: A reference to the mapped_type member of thevalue_type subobject in the container_node_type object pointed to by ptr_[.](#container.node.observers-9.sentence-1) [10](#container.node.observers-10) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2538) *Throws*: Nothing[.](#container.node.observers-10.sentence-1) [🔗](#container.node.observers-itemdecl:4) `constexpr allocator_type get_allocator() const; ` [11](#container.node.observers-11) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2548) *Preconditions*: empty() == false[.](#container.node.observers-11.sentence-1) [12](#container.node.observers-12) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2552) *Returns*: *alloc_[.](#container.node.observers-12.sentence-1) [13](#container.node.observers-13) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2556) *Throws*: Nothing[.](#container.node.observers-13.sentence-1) [🔗](#container.node.observers-itemdecl:5) `constexpr explicit operator bool() const noexcept; ` [14](#container.node.observers-14) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2566) *Returns*: ptr_ != nullptr[.](#container.node.observers-14.sentence-1) [🔗](#container.node.observers-itemdecl:6) `constexpr bool empty() const noexcept; ` [15](#container.node.observers-15) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2576) *Returns*: ptr_ == nullptr[.](#container.node.observers-15.sentence-1) #### [23.2.5.5](#container.node.modifiers) Modifiers [[container.node.modifiers]](container.node.modifiers) [🔗](#container.node.modifiers-itemdecl:1) `constexpr void swap(node-handle& nh) noexcept(ator_traits::propagate_on_container_swap::value || ator_traits::is_always_equal::value); ` [1](#container.node.modifiers-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2590) *Preconditions*: !alloc_, or !nh.alloc_, orator_traits​::​propagate_on_container_swap​::​value is true, or alloc_ == nh.alloc_[.](#container.node.modifiers-1.sentence-1) [2](#container.node.modifiers-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2596) *Effects*: Calls swap(ptr_, nh.ptr_)[.](#container.node.modifiers-2.sentence-1) If !alloc_, or!nh.alloc_, or ator_traits​::​propagate_on_container_swap​::​value is true calls swap(alloc_, nh.alloc_)[.](#container.node.modifiers-2.sentence-2) ### [23.2.6](#container.insert.return) Insert return type [[container.insert.return]](container.insert.return) [1](#container.insert.return-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2605) The associative containers with unique keys and the unordered containers with unique keys have a member function insert that returns a nested type insert_return_type[.](#container.insert.return-1.sentence-1) That return type is a specialization of the template specified in this subclause[.](#container.insert.return-1.sentence-2) templatestruct *insert-return-type*{ Iterator position; bool inserted; NodeType node;}; [2](#container.insert.return-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2620) The name *insert-return-type* is for exposition only[.](#container.insert.return-2.sentence-1) *insert-return-type* has the template parameters, data members, and special members specified above[.](#container.insert.return-2.sentence-2) It has no base classes or members other than those specified[.](#container.insert.return-2.sentence-3) ### [23.2.7](#associative.reqmts) Associative containers [[associative.reqmts]](associative.reqmts) #### [23.2.7.1](#associative.reqmts.general) General [[associative.reqmts.general]](associative.reqmts.general) [1](#associative.reqmts.general-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2630) Associative containers provide fast retrieval of data based on keys[.](#associative.reqmts.general-1.sentence-1) The library provides four basic kinds of associative containers:set,multiset,map andmultimap[.](#associative.reqmts.general-1.sentence-2) The library also provides container adaptors that make it easy to construct abstract data types, such as flat_maps, flat_multimaps,flat_sets, or flat_multisets, out of the basic sequence container kinds (or out of other program-defined sequence containers)[.](#associative.reqmts.general-1.sentence-3) [2](#associative.reqmts.general-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2645) Each associative container is parameterized onKey and an ordering relationCompare that induces a strict weak ordering ([[alg.sorting]](alg.sorting "26.8 Sorting and related operations")) on elements ofKey[.](#associative.reqmts.general-2.sentence-1) In addition,map andmultimap associate an arbitrary [*mapped type*](#def:mapped_type)T with theKey[.](#associative.reqmts.general-2.sentence-2) The object of typeCompare is called the[*comparison object*](#def:comparison_object) of a container[.](#associative.reqmts.general-2.sentence-3) [3](#associative.reqmts.general-3) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2667) The phrase “equivalence of keys” means the equivalence relation imposed by the comparison object[.](#associative.reqmts.general-3.sentence-1) That is, two keysk1 andk2 are considered to be equivalent if for the comparison objectcomp,comp(k1, k2) == false && comp(k2, k1) == false[.](#associative.reqmts.general-3.sentence-2) [*Note [1](#associative.reqmts.general-note-1)*: This is not necessarily the same as the result of k1 == k2[.](#associative.reqmts.general-3.sentence-3) — *end note*] For any two keysk1 andk2 in the same container, callingcomp(k1, k2) shall always return the same value[.](#associative.reqmts.general-3.sentence-4) [4](#associative.reqmts.general-4) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2689) An associative container supports [*unique keys*](#def:unique_keys) if it may contain at most one element for each key[.](#associative.reqmts.general-4.sentence-1) Otherwise, it supports [*equivalent keys*](#def:equivalent_keys)[.](#associative.reqmts.general-4.sentence-2) The set and map classes support unique keys; the multiset and multimap classes support equivalent keys[.](#associative.reqmts.general-4.sentence-3) For multiset and multimap,insert, emplace, and erase preserve the relative ordering of equivalent elements[.](#associative.reqmts.general-4.sentence-4) [5](#associative.reqmts.general-5) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2698) For set and multiset the value type is the same as the key type[.](#associative.reqmts.general-5.sentence-1) For map and multimap it is equal to pair[.](#associative.reqmts.general-5.sentence-2) [6](#associative.reqmts.general-6) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2702) iterator of an associative container is of the bidirectional iterator category[.](#associative.reqmts.general-6.sentence-1) For associative containers where the value type is the same as the key type, bothiterator andconst_iterator are constant iterators[.](#associative.reqmts.general-6.sentence-2) It is unspecified whether or notiterator andconst_iterator are the same type[.](#associative.reqmts.general-6.sentence-3) [*Note [2](#associative.reqmts.general-note-2)*: iterator and const_iterator have identical semantics in this case, and iterator is convertible to const_iterator[.](#associative.reqmts.general-6.sentence-4) Users can avoid violating the one-definition rule by always using const_iterator in their function parameter lists[.](#associative.reqmts.general-6.sentence-5) — *end note*] [7](#associative.reqmts.general-7) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2718) In this subclause, - [(7.1)](#associative.reqmts.general-7.1) X denotes an associative container class, - [(7.2)](#associative.reqmts.general-7.2) a denotes a value of type X, - [(7.3)](#associative.reqmts.general-7.3) a2 denotes a value of a type with nodes compatible with typeX (Table [75](#tab:container.node.compat "Table 75: Container types with compatible nodes")), - [(7.4)](#associative.reqmts.general-7.4) b denotes a value of type X or const X, - [(7.5)](#associative.reqmts.general-7.5) u denotes the name of a variable being declared, - [(7.6)](#associative.reqmts.general-7.6) a_uniq denotes a value of type X when X supports unique keys, - [(7.7)](#associative.reqmts.general-7.7) a_eq denotes a value of type X when X supports equivalent keys, - [(7.8)](#associative.reqmts.general-7.8) a_tran denotes a value of type X or const X when the [*qualified-id*](expr.prim.id.qual#nt:qualified-id "7.5.5.3 Qualified names [expr.prim.id.qual]")X​::​key_compare​::​is_transparent is valid and denotes a type ([[temp.deduct]](temp.deduct "13.10.3 Template argument deduction")), - [(7.9)](#associative.reqmts.general-7.9) i and j meet the *Cpp17InputIterator* requirements and refer to elements implicitly convertible tovalue_type, - [(7.10)](#associative.reqmts.general-7.10) [i, j) denotes a valid range, - [(7.11)](#associative.reqmts.general-7.11) rg denotes a value of a type R that models [*container-compatible-range*](#concept:container-compatible-range "23.2.2.1 Introduction [container.intro.reqmts]"), - [(7.12)](#associative.reqmts.general-7.12) p denotes a valid constant iterator to a, - [(7.13)](#associative.reqmts.general-7.13) q denotes a valid dereferenceable constant iterator to a, - [(7.14)](#associative.reqmts.general-7.14) r denotes a valid dereferenceable iterator to a, - [(7.15)](#associative.reqmts.general-7.15) [q1, q2) denotes a valid range of constant iterators in a, - [(7.16)](#associative.reqmts.general-7.16) il designates an object of type initializer_list, - [(7.17)](#associative.reqmts.general-7.17) t denotes a value of type X​::​value_type, - [(7.18)](#associative.reqmts.general-7.18) k denotes a value of type X​::​key_type, and - [(7.19)](#associative.reqmts.general-7.19) c denotes a value of type X​::​key_compare or const X​::​key_compare; - [(7.20)](#associative.reqmts.general-7.20) kl is a value such that a is partitioned ([[alg.sorting]](alg.sorting "26.8 Sorting and related operations")) with respect to c(x, kl), with x the key value of e and e in a; - [(7.21)](#associative.reqmts.general-7.21) ku is a value such that a is partitioned with respect to!c(ku, x), with x the key value of e and e in a; - [(7.22)](#associative.reqmts.general-7.22) ke is a value such that a is partitioned with respect toc(x, ke) and !c(ke, x), with c(x, ke) implying!c(ke, x) and with x the key value of e and e in a; - [(7.23)](#associative.reqmts.general-7.23) kx is a value such that * [(7.23.1)](#associative.reqmts.general-7.23.1) a is partitioned with respect to c(x, kx) and !c(kx, x), with c(x, kx) implying !c(kx, x) and with x the key value of e and e in a, and * [(7.23.2)](#associative.reqmts.general-7.23.2) kx is not convertible to either iterator or const_iterator; and - [(7.24)](#associative.reqmts.general-7.24) A denotes the storage allocator used by X, if any, or allocator otherwise, - [(7.25)](#associative.reqmts.general-7.25) m denotes an allocator of a type convertible to A, and nh denotes a non-const rvalue of type X​::​node_type[.](#associative.reqmts.general-7.sentence-1) [8](#associative.reqmts.general-8) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2800) A type X meets the [*associative container*](#def:container,associative "23.2.7.1 General [associative.reqmts.general]") requirements if X meets all the requirements of an allocator-aware container ([[container.alloc.reqmts]](#container.alloc.reqmts "23.2.2.5 Allocator-aware containers")) and the following types, statements, and expressions are well-formed and have the specified semantics, except that formap and multimap, the requirements placed on value_type in [[container.reqmts]](#container.reqmts "23.2.2.2 Container requirements") apply instead to key_type and mapped_type[.](#associative.reqmts.general-8.sentence-1) [*Note [3](#associative.reqmts.general-note-3)*: For example, in some cases key_type and mapped_type need to be *Cpp17CopyAssignable* even though the associatedvalue_type, pair, is not*Cpp17CopyAssignable*[.](#associative.reqmts.general-8.sentence-2) — *end note*] [🔗](#lib:key_type,ordered_associative_containers) `typename X::key_type ` [9](#associative.reqmts.general-9) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2836) *Result*: Key[.](#associative.reqmts.general-9.sentence-1) [🔗](#lib:mapped_type,ordered_associative_containers) `typename X::mapped_type ` [10](#associative.reqmts.general-10) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2847) *Result*: T[.](#associative.reqmts.general-10.sentence-1) [11](#associative.reqmts.general-11) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2851) *Remarks*: For map and multimap only[.](#associative.reqmts.general-11.sentence-1) [🔗](#lib:value_type,ordered_associative_containers) `typename X::value_type ` [12](#associative.reqmts.general-12) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2862) *Result*: Key for set and multiset only;pair for map and multimap only[.](#associative.reqmts.general-12.sentence-1) [13](#associative.reqmts.general-13) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2867) *Preconditions*: X​::​value_type is *Cpp17Erasable* from X[.](#associative.reqmts.general-13.sentence-1) [🔗](#lib:key_compare,ordered_associative_containers) `typename X::key_compare ` [14](#associative.reqmts.general-14) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2878) *Result*: Compare[.](#associative.reqmts.general-14.sentence-1) [15](#associative.reqmts.general-15) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2882) *Preconditions*: key_compare is *Cpp17CopyConstructible*[.](#associative.reqmts.general-15.sentence-1) [🔗](#lib:value_compare,ordered_associative_containers) `typename X::value_compare ` [16](#associative.reqmts.general-16) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2893) *Result*: A binary predicate type[.](#associative.reqmts.general-16.sentence-1) It is the same as key_compare for set andmultiset; is an ordering relation on pairs induced by the first component (i.e., Key) for map and multimap[.](#associative.reqmts.general-16.sentence-2) [🔗](#lib:node_type,ordered_associative_containers) `typename X::node_type ` [17](#associative.reqmts.general-17) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2907) *Result*: A specialization of the *node-handle* class template ([[container.node]](#container.node "23.2.5 Node handles")), such that the public nested types are the same types as the corresponding types in X[.](#associative.reqmts.general-17.sentence-1) [🔗](#lib:set,constructor) `X(c) ` [18](#associative.reqmts.general-18) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2924) *Effects*: Constructs an empty container[.](#associative.reqmts.general-18.sentence-1) Uses a copy of c as a comparison object[.](#associative.reqmts.general-18.sentence-2) [19](#associative.reqmts.general-19) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2929) *Complexity*: Constant[.](#associative.reqmts.general-19.sentence-1) [🔗](#lib:set,constructor_) `X u = X(); X u; ` [20](#associative.reqmts.general-20) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2944) *Preconditions*: key_compare meets the *Cpp17DefaultConstructible* requirements[.](#associative.reqmts.general-20.sentence-1) [21](#associative.reqmts.general-21) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2948) *Effects*: Constructs an empty container[.](#associative.reqmts.general-21.sentence-1) Uses Compare() as a comparison object[.](#associative.reqmts.general-21.sentence-2) [22](#associative.reqmts.general-22) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2953) *Complexity*: Constant[.](#associative.reqmts.general-22.sentence-1) [🔗](#lib:set,constructor__) `X(i, j, c) ` [23](#associative.reqmts.general-23) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2967) *Preconditions*: value_type is*Cpp17EmplaceConstructible* into X from *i[.](#associative.reqmts.general-23.sentence-1) [24](#associative.reqmts.general-24) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2972) *Effects*: Constructs an empty container and inserts elements from the range [i, j) into it; uses c as a comparison object[.](#associative.reqmts.general-24.sentence-1) [25](#associative.reqmts.general-25) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2978) *Complexity*: NlogN in general, where N has the value distance(i, j); linear if [i, j) is sorted with respect to value_comp()[.](#associative.reqmts.general-25.sentence-1) [🔗](#lib:set,constructor___) `X(i, j) ` [26](#associative.reqmts.general-26) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2993) *Preconditions*: key_compare meets the *Cpp17DefaultConstructible* requirements[.](#associative.reqmts.general-26.sentence-1) value_type is*Cpp17EmplaceConstructible* into X from *i[.](#associative.reqmts.general-26.sentence-2) [27](#associative.reqmts.general-27) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2999) *Effects*: Constructs an empty container and inserts elements from the range [i, j) into it; uses Compare() as a comparison object[.](#associative.reqmts.general-27.sentence-1) [28](#associative.reqmts.general-28) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3005) *Complexity*: NlogN in general, where N has the value distance(i, j); linear if [i, j) is sorted with respect to value_comp()[.](#associative.reqmts.general-28.sentence-1) [🔗](#lib:set,constructor____) `X(from_range, rg, c) ` [29](#associative.reqmts.general-29) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3020) *Preconditions*: value_type is*Cpp17EmplaceConstructible* into X from *ranges​::​begin(rg)[.](#associative.reqmts.general-29.sentence-1) [30](#associative.reqmts.general-30) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3026) *Effects*: Constructs an empty container and inserts each element from rg into it[.](#associative.reqmts.general-30.sentence-1) Uses c as the comparison object[.](#associative.reqmts.general-30.sentence-2) [31](#associative.reqmts.general-31) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3032) *Complexity*: NlogN in general, where N has the value ranges​::​distance(rg); linear if rg is sorted with respect to value_comp()[.](#associative.reqmts.general-31.sentence-1) [🔗](#lib:set,constructor_____) `X(from_range, rg) ` [32](#associative.reqmts.general-32) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3047) *Preconditions*: key_compare meets the *Cpp17DefaultConstructible* requirements[.](#associative.reqmts.general-32.sentence-1) value_type is *Cpp17EmplaceConstructible* into X from *ranges​::​begin(rg)[.](#associative.reqmts.general-32.sentence-2) [33](#associative.reqmts.general-33) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3053) *Effects*: Constructs an empty container and inserts each element from rg into it[.](#associative.reqmts.general-33.sentence-1) Uses Compare() as the comparison object[.](#associative.reqmts.general-33.sentence-2) [34](#associative.reqmts.general-34) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3059) *Complexity*: Same as X(from_range, rg, c)[.](#associative.reqmts.general-34.sentence-1) [🔗](#lib:set,constructor______) `X(il, c) ` [35](#associative.reqmts.general-35) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3073) *Effects*: Equivalent to X(il.begin(), il.end(), c)[.](#associative.reqmts.general-35.sentence-1) [🔗](#lib:set,constructor_______) `X(il) ` [36](#associative.reqmts.general-36) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3087) *Effects*: Equivalent to X(il.begin(), il.end())[.](#associative.reqmts.general-36.sentence-1) [🔗](#associative.reqmts.general-itemdecl:15) `a = il ` [37](#associative.reqmts.general-37) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3097) *Result*: X& [38](#associative.reqmts.general-38) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3101) *Preconditions*: value_type is *Cpp17CopyInsertable* into X and *Cpp17CopyAssignable*[.](#associative.reqmts.general-38.sentence-1) [39](#associative.reqmts.general-39) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3106) *Effects*: Assigns the range [il.begin(), il.end()) into a[.](#associative.reqmts.general-39.sentence-1) All existing elements of a are either assigned to or destroyed[.](#associative.reqmts.general-39.sentence-2) [40](#associative.reqmts.general-40) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3111) *Complexity*: NlogN in general, where N has the value il.size() + a.size(); linear if [il.begin(), il.end()) is sorted with respect to value_comp()[.](#associative.reqmts.general-40.sentence-1) [🔗](#lib:key_comp,ordered_associative_containers) `b.key_comp() ` [41](#associative.reqmts.general-41) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3123) *Result*: X​::​key_compare [42](#associative.reqmts.general-42) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3127) *Returns*: The comparison object out of which b was constructed[.](#associative.reqmts.general-42.sentence-1) [43](#associative.reqmts.general-43) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3131) *Complexity*: Constant[.](#associative.reqmts.general-43.sentence-1) [🔗](#lib:value_comp,ordered_associative_containers) `b.value_comp() ` [44](#associative.reqmts.general-44) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3142) *Result*: X​::​value_compare [45](#associative.reqmts.general-45) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3146) *Returns*: An object of value_compare constructed out of the comparison object[.](#associative.reqmts.general-45.sentence-1) [46](#associative.reqmts.general-46) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3150) *Complexity*: Constant[.](#associative.reqmts.general-46.sentence-1) [🔗](#lib:emplace,ordered_associative_containers) `a_uniq.emplace(args) ` [47](#associative.reqmts.general-47) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3161) *Result*: pair [48](#associative.reqmts.general-48) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3165) *Preconditions*: value_type is*Cpp17EmplaceConstructible* into X from args[.](#associative.reqmts.general-48.sentence-1) [49](#associative.reqmts.general-49) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3170) *Effects*: Inserts a value_type object t constructed with std​::​forward(args)... if and only if there is no element in the container with key equivalent to the key of t[.](#associative.reqmts.general-49.sentence-1) [50](#associative.reqmts.general-50) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3177) *Returns*: The bool component of the returned pair is true if and only if the insertion takes place, and the iterator component of the pair points to the element with key equivalent to the key of t[.](#associative.reqmts.general-50.sentence-1) [51](#associative.reqmts.general-51) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3184) *Complexity*: Logarithmic[.](#associative.reqmts.general-51.sentence-1) [🔗](#lib:emplace,ordered_associative_containers_) `a_eq.emplace(args) ` [52](#associative.reqmts.general-52) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3195) *Result*: iterator [53](#associative.reqmts.general-53) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3199) *Preconditions*: value_type is*Cpp17EmplaceConstructible* into X from args[.](#associative.reqmts.general-53.sentence-1) [54](#associative.reqmts.general-54) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3204) *Effects*: Inserts a value_type object t constructed with std​::​forward(args)...[.](#associative.reqmts.general-54.sentence-1) If a range containing elements equivalent to t exists in a_eq,t is inserted at the end of that range[.](#associative.reqmts.general-54.sentence-2) [55](#associative.reqmts.general-55) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3211) *Returns*: An iterator pointing to the newly inserted element[.](#associative.reqmts.general-55.sentence-1) [56](#associative.reqmts.general-56) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3215) *Complexity*: Logarithmic[.](#associative.reqmts.general-56.sentence-1) [🔗](#lib:emplace_hint,ordered_associative_containers) `a.emplace_hint(p, args) ` [57](#associative.reqmts.general-57) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3226) *Result*: iterator [58](#associative.reqmts.general-58) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3230) *Effects*: Equivalent to a.emplace(std​::​forward(args)...), except that the element is inserted as close as possible to the position just prior to p[.](#associative.reqmts.general-58.sentence-1) [59](#associative.reqmts.general-59) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3236) *Returns*: The iterator returned by emplace[.](#associative.reqmts.general-59.sentence-1) [60](#associative.reqmts.general-60) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3240) *Complexity*: Logarithmic in general, but amortized constant if the element is inserted right before p[.](#associative.reqmts.general-60.sentence-1) [🔗](#lib:insert,ordered_associative_containers) `a_uniq.insert(t) ` [61](#associative.reqmts.general-61) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3252) *Result*: pair [62](#associative.reqmts.general-62) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3256) *Preconditions*: If t is a non-const rvalue,value_type is *Cpp17MoveInsertable* into X; otherwise, value_type is *Cpp17CopyInsertable* into X[.](#associative.reqmts.general-62.sentence-1) [63](#associative.reqmts.general-63) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3262) *Effects*: Inserts t if and only if there is no element in the container with key equivalent to the key of t[.](#associative.reqmts.general-63.sentence-1) [64](#associative.reqmts.general-64) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3267) *Returns*: The bool component of the returned pair is true if and only if the insertion takes place, and the iterator component of the pair points to the element with key equivalent to the key of t[.](#associative.reqmts.general-64.sentence-1) [65](#associative.reqmts.general-65) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3274) *Complexity*: Logarithmic[.](#associative.reqmts.general-65.sentence-1) [🔗](#lib:insert,ordered_associative_containers_) `a_eq.insert(t) ` [66](#associative.reqmts.general-66) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3285) *Result*: iterator [67](#associative.reqmts.general-67) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3289) *Preconditions*: If t is a non-const rvalue,value_type is *Cpp17MoveInsertable* into X; otherwise, value_type is *Cpp17CopyInsertable* into X[.](#associative.reqmts.general-67.sentence-1) [68](#associative.reqmts.general-68) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3295) *Effects*: Inserts t and returns the iterator pointing to the newly inserted element[.](#associative.reqmts.general-68.sentence-1) If a range containing elements equivalent to t exists in a_eq,t is inserted at the end of that range[.](#associative.reqmts.general-68.sentence-2) [69](#associative.reqmts.general-69) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3302) *Complexity*: Logarithmic[.](#associative.reqmts.general-69.sentence-1) [🔗](#lib:insert,ordered_associative_containers__) `a.insert(p, t) ` [70](#associative.reqmts.general-70) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3313) *Result*: iterator [71](#associative.reqmts.general-71) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3317) *Preconditions*: If t is a non-const rvalue,value_type is *Cpp17MoveInsertable* into X; otherwise, value_type is *Cpp17CopyInsertable* into X[.](#associative.reqmts.general-71.sentence-1) [72](#associative.reqmts.general-72) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3323) *Effects*: Inserts t if and only if there is no element with key equivalent to the key of t in containers with unique keys; always inserts t in containers with equivalent keys[.](#associative.reqmts.general-72.sentence-1) t is inserted as close as possible to the position just prior to p[.](#associative.reqmts.general-72.sentence-2) [73](#associative.reqmts.general-73) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3331) *Returns*: An iterator pointing to the element with key equivalent to the key of t[.](#associative.reqmts.general-73.sentence-1) [74](#associative.reqmts.general-74) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3335) *Complexity*: Logarithmic in general, but amortized constant if t is inserted right before p[.](#associative.reqmts.general-74.sentence-1) [🔗](#lib:insert,ordered_associative_containers___) `a.insert(i, j) ` [75](#associative.reqmts.general-75) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3347) *Result*: void [76](#associative.reqmts.general-76) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3351) *Preconditions*: value_type is*Cpp17EmplaceConstructible* into X from *i[.](#associative.reqmts.general-76.sentence-1) Neither i nor j are iterators into a[.](#associative.reqmts.general-76.sentence-2) [77](#associative.reqmts.general-77) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3357) *Effects*: Inserts each element from the range [i, j) if and only if there is no element with key equivalent to the key of that element in containers with unique keys; always inserts that element in containers with equivalent keys[.](#associative.reqmts.general-77.sentence-1) [78](#associative.reqmts.general-78) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3364) *Complexity*: Nlog(a.size()+N), where N has the value distance(i, j)[.](#associative.reqmts.general-78.sentence-1) [🔗](#lib:insert,ordered_associative_containers____) `a.insert_range(rg) ` [79](#associative.reqmts.general-79) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3375) *Result*: void [80](#associative.reqmts.general-80) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3379) *Preconditions*: value_type is*Cpp17EmplaceConstructible* into X from *ranges​::​begin(rg)[.](#associative.reqmts.general-80.sentence-1) rg and a do not overlap[.](#associative.reqmts.general-80.sentence-2) [81](#associative.reqmts.general-81) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3386) *Effects*: Inserts each element from rg if and only if there is no element with key equivalent to the key of that element in containers with unique keys; always inserts that element in containers with equivalent keys[.](#associative.reqmts.general-81.sentence-1) [82](#associative.reqmts.general-82) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3393) *Complexity*: Nlog(a.size()+N), where N has the value ranges​::​distance(rg)[.](#associative.reqmts.general-82.sentence-1) [🔗](#lib:insert,ordered_associative_containers_____) `a.insert(il) ` [83](#associative.reqmts.general-83) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3405) *Effects*: Equivalent to a.insert(il.begin(), il.end())[.](#associative.reqmts.general-83.sentence-1) [🔗](#lib:insert,ordered_associative_containers______) `a_uniq.insert(nh) ` [84](#associative.reqmts.general-84) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3416) *Result*: insert_return_type [85](#associative.reqmts.general-85) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3420) *Preconditions*: nh is empty ora_uniq.get_allocator() == nh.get_allocator() is true[.](#associative.reqmts.general-85.sentence-1) [86](#associative.reqmts.general-86) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3425) *Effects*: If nh is empty, has no effect[.](#associative.reqmts.general-86.sentence-1) Otherwise, inserts the element owned by nh if and only if there is no element in the container with a key equivalent to nh.key()[.](#associative.reqmts.general-86.sentence-2) [87](#associative.reqmts.general-87) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3431) *Returns*: If nh is empty, inserted is false,position is end(), and node is empty[.](#associative.reqmts.general-87.sentence-1) Otherwise if the insertion took place, inserted is true,position points to the inserted element, and node is empty; if the insertion failed, inserted is false,node has the previous value of nh, andposition points to an element with a key equivalent to nh.key()[.](#associative.reqmts.general-87.sentence-2) [88](#associative.reqmts.general-88) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3441) *Complexity*: Logarithmic[.](#associative.reqmts.general-88.sentence-1) [🔗](#lib:insert,ordered_associative_containers_______) `a_eq.insert(nh) ` [89](#associative.reqmts.general-89) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3452) *Result*: iterator [90](#associative.reqmts.general-90) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3456) *Preconditions*: nh is empty ora_eq.get_allocator() == nh.get_allocator() is true[.](#associative.reqmts.general-90.sentence-1) [91](#associative.reqmts.general-91) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3461) *Effects*: If nh is empty, has no effect and returns a_eq.end()[.](#associative.reqmts.general-91.sentence-1) Otherwise, inserts the element owned by nh and returns an iterator pointing to the newly inserted element[.](#associative.reqmts.general-91.sentence-2) If a range containing elements with keys equivalent to nh.key() exists in a_eq, the element is inserted at the end of that range[.](#associative.reqmts.general-91.sentence-3) [92](#associative.reqmts.general-92) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3470) *Postconditions*: nh is empty[.](#associative.reqmts.general-92.sentence-1) [93](#associative.reqmts.general-93) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3474) *Complexity*: Logarithmic[.](#associative.reqmts.general-93.sentence-1) [🔗](#lib:insert,ordered_associative_containers________) `a.insert(p, nh) ` [94](#associative.reqmts.general-94) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3485) *Result*: iterator [95](#associative.reqmts.general-95) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3489) *Preconditions*: nh is empty ora.get_allocator() == nh.get_allocator() is true[.](#associative.reqmts.general-95.sentence-1) [96](#associative.reqmts.general-96) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3494) *Effects*: If nh is empty, has no effect and returns a.end()[.](#associative.reqmts.general-96.sentence-1) Otherwise, inserts the element owned by nh if and only if there is no element with key equivalent to nh.key() in containers with unique keys; always inserts the element owned by nh in containers with equivalent keys[.](#associative.reqmts.general-96.sentence-2) The element is inserted as close as possible to the position just prior to p[.](#associative.reqmts.general-96.sentence-3) [97](#associative.reqmts.general-97) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3505) *Postconditions*: nh is empty if insertion succeeds, unchanged if insertion fails[.](#associative.reqmts.general-97.sentence-1) [98](#associative.reqmts.general-98) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3509) *Returns*: An iterator pointing to the element with key equivalent to nh.key()[.](#associative.reqmts.general-98.sentence-1) [99](#associative.reqmts.general-99) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3513) *Complexity*: Logarithmic in general, but amortized constant if the element is inserted right before p[.](#associative.reqmts.general-99.sentence-1) [🔗](#lib:extract,ordered_associative_containers) `a.extract(k) ` [100](#associative.reqmts.general-100) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3526) *Result*: node_type [101](#associative.reqmts.general-101) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3530) *Effects*: Removes the first element in the container with key equivalent to k[.](#associative.reqmts.general-101.sentence-1) [102](#associative.reqmts.general-102) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3534) *Returns*: A node_type owning the element if found, otherwise an empty node_type[.](#associative.reqmts.general-102.sentence-1) [103](#associative.reqmts.general-103) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3539) *Complexity*: log(a.size()) [🔗](#lib:extract,ordered_associative_containers_) `a_tran.extract(kx) ` [104](#associative.reqmts.general-104) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3550) *Result*: node_type [105](#associative.reqmts.general-105) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3554) *Effects*: Removes the first element in the container with key r such that !c(r, kx) && !c(kx, r) is true[.](#associative.reqmts.general-105.sentence-1) [106](#associative.reqmts.general-106) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3559) *Returns*: A node_type owning the element if found, otherwise an empty node_type[.](#associative.reqmts.general-106.sentence-1) [107](#associative.reqmts.general-107) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3564) *Complexity*: log(a_tran.size()) [🔗](#lib:extract,ordered_associative_containers__) `a.extract(q) ` [108](#associative.reqmts.general-108) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3575) *Result*: node_type [109](#associative.reqmts.general-109) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3579) *Effects*: Removes the element pointed to by q[.](#associative.reqmts.general-109.sentence-1) [110](#associative.reqmts.general-110) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3583) *Returns*: A node_type owning that element[.](#associative.reqmts.general-110.sentence-1) [111](#associative.reqmts.general-111) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3587) *Complexity*: Amortized constant[.](#associative.reqmts.general-111.sentence-1) [🔗](#lib:merge,ordered_associative_containers) `a.merge(a2) ` [112](#associative.reqmts.general-112) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3598) *Result*: void [113](#associative.reqmts.general-113) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3602) *Preconditions*: a.get_allocator() == a2.get_allocator() is true[.](#associative.reqmts.general-113.sentence-1) [114](#associative.reqmts.general-114) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3606) *Effects*: Attempts to extract each element in a2 and insert it into a using the comparison object of a[.](#associative.reqmts.general-114.sentence-1) In containers with unique keys, if there is an element in a with key equivalent to the key of an element from a2, then that element is not extracted from a2[.](#associative.reqmts.general-114.sentence-2) [115](#associative.reqmts.general-115) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3615) *Postconditions*: Pointers and references to the transferred elements of a2 refer to those same elements but as members of a[.](#associative.reqmts.general-115.sentence-1) If a.begin() and a2.begin() have the same type, iterators referring to the transferred elements will continue to refer to their elements, but they now behave as iterators into a, not into a2[.](#associative.reqmts.general-115.sentence-2) [116](#associative.reqmts.general-116) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3624) *Throws*: Nothing unless the comparison object throws[.](#associative.reqmts.general-116.sentence-1) [117](#associative.reqmts.general-117) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3628) *Complexity*: Nlog(a.size()+N), where N has the value a2.size()[.](#associative.reqmts.general-117.sentence-1) [🔗](#lib:erase,ordered_associative_containers) `a.erase(k) ` [118](#associative.reqmts.general-118) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3639) *Result*: size_type [119](#associative.reqmts.general-119) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3643) *Effects*: Erases all elements in the container with key equivalent to k[.](#associative.reqmts.general-119.sentence-1) [120](#associative.reqmts.general-120) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3647) *Returns*: The number of erased elements[.](#associative.reqmts.general-120.sentence-1) [121](#associative.reqmts.general-121) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3651) *Complexity*: log(a.size())+a.count(k) [🔗](#lib:erase,ordered_associative_containers_) `a_tran.erase(kx) ` [122](#associative.reqmts.general-122) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3662) *Result*: size_type [123](#associative.reqmts.general-123) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3666) *Effects*: Erases all elements in the container with key r such that !c(r, kx) && !c(kx, r) is true[.](#associative.reqmts.general-123.sentence-1) [124](#associative.reqmts.general-124) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3671) *Returns*: The number of erased elements[.](#associative.reqmts.general-124.sentence-1) [125](#associative.reqmts.general-125) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3675) *Complexity*: log(a_tran.size())+a_tran.count(kx) [🔗](#lib:erase,ordered_associative_containers__) `a.erase(q) ` [126](#associative.reqmts.general-126) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3686) *Result*: iterator [127](#associative.reqmts.general-127) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3690) *Effects*: Erases the element pointed to by q[.](#associative.reqmts.general-127.sentence-1) [128](#associative.reqmts.general-128) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3694) *Returns*: An iterator pointing to the element immediately following q prior to the element being erased[.](#associative.reqmts.general-128.sentence-1) If no such element exists, returns a.end()[.](#associative.reqmts.general-128.sentence-2) [129](#associative.reqmts.general-129) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3700) *Complexity*: Amortized constant[.](#associative.reqmts.general-129.sentence-1) [🔗](#lib:erase,ordered_associative_containers___) `a.erase(r) ` [130](#associative.reqmts.general-130) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3711) *Result*: iterator [131](#associative.reqmts.general-131) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3715) *Effects*: Erases the element pointed to by r[.](#associative.reqmts.general-131.sentence-1) [132](#associative.reqmts.general-132) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3719) *Returns*: An iterator pointing to the element immediately following r prior to the element being erased[.](#associative.reqmts.general-132.sentence-1) If no such element exists, returns a.end()[.](#associative.reqmts.general-132.sentence-2) [133](#associative.reqmts.general-133) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3725) *Complexity*: Amortized constant[.](#associative.reqmts.general-133.sentence-1) [🔗](#lib:erase,ordered_associative_containers____) `a.erase(q1, q2) ` [134](#associative.reqmts.general-134) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3736) *Result*: iterator [135](#associative.reqmts.general-135) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3740) *Effects*: Erases all the elements in the range [q1, q2)[.](#associative.reqmts.general-135.sentence-1) [136](#associative.reqmts.general-136) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3744) *Returns*: An iterator pointing to the element pointed to by q2 prior to any elements being erased[.](#associative.reqmts.general-136.sentence-1) If no such element exists, a.end() is returned[.](#associative.reqmts.general-136.sentence-2) [137](#associative.reqmts.general-137) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3750) *Complexity*: log(a.size())+N, where N has the value distance(q1, q2)[.](#associative.reqmts.general-137.sentence-1) [🔗](#lib:clear,ordered_associative_containers) `a.clear() ` [138](#associative.reqmts.general-138) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3761) *Effects*: Equivalent to a.erase(a.begin(), a.end())[.](#associative.reqmts.general-138.sentence-1) [139](#associative.reqmts.general-139) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3765) *Postconditions*: a.empty() is true[.](#associative.reqmts.general-139.sentence-1) [140](#associative.reqmts.general-140) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3769) *Complexity*: Linear in a.size()[.](#associative.reqmts.general-140.sentence-1) [🔗](#lib:find,ordered_associative_containers) `b.find(k) ` [141](#associative.reqmts.general-141) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3780) *Result*: iterator; const_iterator for constant b[.](#associative.reqmts.general-141.sentence-1) [142](#associative.reqmts.general-142) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3784) *Returns*: An iterator pointing to an element with the key equivalent to k, orb.end() if such an element is not found[.](#associative.reqmts.general-142.sentence-1) [143](#associative.reqmts.general-143) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3789) *Complexity*: Logarithmic[.](#associative.reqmts.general-143.sentence-1) [🔗](#lib:find,ordered_associative_containers_) `a_tran.find(ke) ` [144](#associative.reqmts.general-144) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3800) *Result*: iterator; const_iterator for constant a_tran[.](#associative.reqmts.general-144.sentence-1) [145](#associative.reqmts.general-145) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3804) *Returns*: An iterator pointing to an element with key r such that !c(r, ke) && !c(ke, r) is true, ora_tran.end() if such an element is not found[.](#associative.reqmts.general-145.sentence-1) [146](#associative.reqmts.general-146) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3810) *Complexity*: Logarithmic[.](#associative.reqmts.general-146.sentence-1) [🔗](#lib:count,ordered_associative_containers) `b.count(k) ` [147](#associative.reqmts.general-147) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3821) *Result*: size_type [148](#associative.reqmts.general-148) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3825) *Returns*: The number of elements with key equivalent to k[.](#associative.reqmts.general-148.sentence-1) [149](#associative.reqmts.general-149) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3829) *Complexity*: log(b.size())+b.count(k) [🔗](#lib:count,ordered_associative_containers_) `a_tran.count(ke) ` [150](#associative.reqmts.general-150) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3840) *Result*: size_type [151](#associative.reqmts.general-151) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3844) *Returns*: The number of elements with key r such that !c(r, ke) && !c(ke, r)[.](#associative.reqmts.general-151.sentence-1) [152](#associative.reqmts.general-152) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3849) *Complexity*: log(a_tran.size())+a_tran.count(ke) [🔗](#lib:contains,ordered_associative_containers) `b.contains(k) ` [153](#associative.reqmts.general-153) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3860) *Result*: bool [154](#associative.reqmts.general-154) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3864) *Effects*: Equivalent to: return b.find(k) != b.end(); [🔗](#lib:contains,ordered_associative_containers_) `a_tran.contains(ke) ` [155](#associative.reqmts.general-155) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3875) *Result*: bool [156](#associative.reqmts.general-156) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3879) *Effects*: Equivalent to: return a_tran.find(ke) != a_tran.end(); [🔗](#lib:lower_bound,ordered_associative_containers) `b.lower_bound(k) ` [157](#associative.reqmts.general-157) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3890) *Result*: iterator; const_iterator for constant b[.](#associative.reqmts.general-157.sentence-1) [158](#associative.reqmts.general-158) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3894) *Returns*: An iterator pointing to the first element with key not less than k, or b.end() if such an element is not found[.](#associative.reqmts.general-158.sentence-1) [159](#associative.reqmts.general-159) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3899) *Complexity*: Logarithmic[.](#associative.reqmts.general-159.sentence-1) [🔗](#lib:lower_bound,ordered_associative_containers_) `a_tran.lower_bound(kl) ` [160](#associative.reqmts.general-160) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3910) *Result*: iterator; const_iterator for constant a_tran[.](#associative.reqmts.general-160.sentence-1) [161](#associative.reqmts.general-161) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3914) *Returns*: An iterator pointing to the first element with key r such that !c(r, kl), or a_tran.end() if such an element is not found[.](#associative.reqmts.general-161.sentence-1) [162](#associative.reqmts.general-162) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3920) *Complexity*: Logarithmic[.](#associative.reqmts.general-162.sentence-1) [🔗](#lib:upper_bound,ordered_associative_containers) `b.upper_bound(k) ` [163](#associative.reqmts.general-163) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3931) *Result*: iterator; const_iterator for constant b[.](#associative.reqmts.general-163.sentence-1) [164](#associative.reqmts.general-164) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3935) *Returns*: An iterator pointing to the first element with key greater than k, or b.end() if such an element is not found[.](#associative.reqmts.general-164.sentence-1) [165](#associative.reqmts.general-165) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3940) *Complexity*: Logarithmic[.](#associative.reqmts.general-165.sentence-1) [🔗](#lib:upper_bound,ordered_associative_containers_) `a_tran.upper_bound(ku) ` [166](#associative.reqmts.general-166) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3951) *Result*: iterator; const_iterator for constant a_tran[.](#associative.reqmts.general-166.sentence-1) [167](#associative.reqmts.general-167) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3955) *Returns*: An iterator pointing to the first element with key r such that c(ku, r), or a_tran.end() if such an element is not found[.](#associative.reqmts.general-167.sentence-1) [168](#associative.reqmts.general-168) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3961) *Complexity*: Logarithmic[.](#associative.reqmts.general-168.sentence-1) [🔗](#lib:equal_range,ordered_associative_containers) `b.equal_range(k) ` [169](#associative.reqmts.general-169) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3972) *Result*: pair;pair for constant b[.](#associative.reqmts.general-169.sentence-1) [170](#associative.reqmts.general-170) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3977) *Effects*: Equivalent to: return make_pair(b.lower_bound(k), b.upper_bound(k)); [171](#associative.reqmts.general-171) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3981) *Complexity*: Logarithmic[.](#associative.reqmts.general-171.sentence-1) [🔗](#lib:equal_range,ordered_associative_containers_) `a_tran.equal_range(ke) ` [172](#associative.reqmts.general-172) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3992) *Result*: pair;pair for constant a_tran[.](#associative.reqmts.general-172.sentence-1) [173](#associative.reqmts.general-173) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3997) *Effects*: Equivalent to:return make_pair(a_tran.lower_bound(ke), a_tran.upper_bound(ke)); [174](#associative.reqmts.general-174) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4002) *Complexity*: Logarithmic[.](#associative.reqmts.general-174.sentence-1) [175](#associative.reqmts.general-175) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4007) The insert, insert_range, and emplace members shall not affect the validity of iterators and references to the container, and the erase members shall invalidate only iterators and references to the erased elements[.](#associative.reqmts.general-175.sentence-1) [176](#associative.reqmts.general-176) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4014) The extract members invalidate only iterators to the removed element; pointers and references to the removed element remain valid[.](#associative.reqmts.general-176.sentence-1) However, accessing the element through such pointers and references while the element is owned by a node_type is undefined behavior[.](#associative.reqmts.general-176.sentence-2) References and pointers to an element obtained while it is owned by a node_type are invalidated if the element is successfully inserted[.](#associative.reqmts.general-176.sentence-3) [177](#associative.reqmts.general-177) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4022) The fundamental property of iterators of associative containers is that they iterate through the containers in the non-descending order of keys where non-descending is defined by the comparison that was used to construct them[.](#associative.reqmts.general-177.sentence-1) For any two dereferenceable iteratorsi andj such that distance fromi toj is positive, the following condition holds:value_comp(*j, *i) == false [178](#associative.reqmts.general-178) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4039) For associative containers with unique keys the stronger condition holds:value_comp(*i, *j) != false [179](#associative.reqmts.general-179) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4045) When an associative container is constructed by passing a comparison object the container shall not store a pointer or reference to the passed object, even if that object is passed by reference[.](#associative.reqmts.general-179.sentence-1) When an associative container is copied, through either a copy constructor or an assignment operator, the target container shall then use the comparison object from the container being copied, as if that comparison object had been passed to the target container in its constructor[.](#associative.reqmts.general-179.sentence-2) [180](#associative.reqmts.general-180) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4056) The member function templatesfind, count, contains,lower_bound, upper_bound, equal_range,erase, and extract shall not participate in overload resolution unless the [*qualified-id*](expr.prim.id.qual#nt:qualified-id "7.5.5.3 Qualified names [expr.prim.id.qual]") Compare​::​is_transparent is valid and denotes a type ([[temp.deduct]](temp.deduct "13.10.3 Template argument deduction"))[.](#associative.reqmts.general-180.sentence-1) Additionally, the member function templates extract and erase shall not participate in overload resolution ifis_convertible_v || is_convertible_v is true, where K is the type substituted as the first template argument[.](#associative.reqmts.general-180.sentence-2) [181](#associative.reqmts.general-181) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4070) A deduction guide for an associative container shall not participate in overload resolution if any of the following are true: - [(181.1)](#associative.reqmts.general-181.1) It has an InputIterator template parameter and a type that does not qualify as an input iterator is deduced for that parameter[.](#associative.reqmts.general-181.1.sentence-1) - [(181.2)](#associative.reqmts.general-181.2) It has an Allocator template parameter and a type that does not qualify as an allocator is deduced for that parameter[.](#associative.reqmts.general-181.2.sentence-1) - [(181.3)](#associative.reqmts.general-181.3) It has a Compare template parameter and a type that qualifies as an allocator is deduced for that parameter[.](#associative.reqmts.general-181.3.sentence-1) #### [23.2.7.2](#associative.reqmts.except) Exception safety guarantees [[associative.reqmts.except]](associative.reqmts.except) [1](#associative.reqmts.except-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4088) For associative containers, no clear() function throws an exception[.](#associative.reqmts.except-1.sentence-1) erase(k) does not throw an exception unless that exception is thrown by the container's Compare object (if any)[.](#associative.reqmts.except-1.sentence-2) [2](#associative.reqmts.except-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4093) For associative containers, if an exception is thrown by any operation from within an insert or emplace function inserting a single element, the insertion has no effect[.](#associative.reqmts.except-2.sentence-1) [3](#associative.reqmts.except-3) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4098) For associative containers, no swap function throws an exception unless that exception is thrown by the swap of the container's Compare object (if any)[.](#associative.reqmts.except-3.sentence-1) ### [23.2.8](#unord.req) Unordered associative containers [[unord.req]](unord.req) #### [23.2.8.1](#unord.req.general) General [[unord.req.general]](unord.req.general) [1](#unord.req.general-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4109) Unordered associative containers provide an ability for fast retrieval of data based on keys[.](#unord.req.general-1.sentence-1) The worst-case complexity for most operations is linear, but the average case is much faster[.](#unord.req.general-1.sentence-2) The library provides four unordered associative containers: unordered_set,unordered_map, unordered_multiset, andunordered_multimap[.](#unord.req.general-1.sentence-3) [2](#unord.req.general-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4118) Unordered associative containers conform to the requirements for Containers ([container.requirements]), except that the expressionsa == b and a != b have different semantics than for the other container types[.](#unord.req.general-2.sentence-1) [3](#unord.req.general-3) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4128) Each unordered associative container is parameterized by Key, by a function object type Hash that meets the *Cpp17Hash* requirements ([[hash.requirements]](hash.requirements "16.4.4.5 Cpp17Hash requirements")) and acts as a hash function for argument values of type Key, and by a binary predicate Pred that induces an equivalence relation on values of type Key[.](#unord.req.general-3.sentence-1) Additionally, unordered_map and unordered_multimap associate an arbitrary *mapped type* T with the Key[.](#unord.req.general-3.sentence-2) [4](#unord.req.general-4) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4137) The container's object of type Hash — denoted byhash — is called the [*hash function*](#def:hash_function) of the container[.](#unord.req.general-4.sentence-1) The container's object of type Pred — denoted by pred — is called the[*key equality predicate*](#def:key_equality_predicate) of the container[.](#unord.req.general-4.sentence-2) [5](#unord.req.general-5) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4146) Two values k1 and k2 are considered equivalent if the container's key equality predicatepred(k1, k2) is valid and returnstrue when passed those values[.](#unord.req.general-5.sentence-1) If k1 andk2 are equivalent, the container's hash function shall return the same value for both[.](#unord.req.general-5.sentence-2) [*Note [1](#unord.req.general-note-1)*: Thus, when an unordered associative container is instantiated with a non-default Pred parameter it usually needs a non-default Hash parameter as well[.](#unord.req.general-5.sentence-3) — *end note*] For any two keys k1 and k2 in the same container, calling pred(k1, k2) shall always return the same value[.](#unord.req.general-5.sentence-4) For any key k in a container, calling hash(k) shall always return the same value[.](#unord.req.general-5.sentence-5) [6](#unord.req.general-6) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4165) An unordered associative container supports *unique keys* if it may contain at most one element for each key[.](#unord.req.general-6.sentence-1) Otherwise, it supports*equivalent keys*[.](#unord.req.general-6.sentence-2) unordered_set and unordered_map support unique keys[.](#unord.req.general-6.sentence-3) unordered_multiset and unordered_multimap support equivalent keys[.](#unord.req.general-6.sentence-4) In containers that support equivalent keys, elements with equivalent keys are adjacent to each other in the iteration order of the container[.](#unord.req.general-6.sentence-5) Thus, although the absolute order of elements in an unordered container is not specified, its elements are grouped into [*equivalent-key groups*](#def:equivalent-key_group "23.2.8.1 General [unord.req.general]") such that all elements of each group have equivalent keys[.](#unord.req.general-6.sentence-6) Mutating operations on unordered containers shall preserve the relative order of elements within each equivalent-key group unless otherwise specified[.](#unord.req.general-6.sentence-7) [7](#unord.req.general-7) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4181) For unordered_set and unordered_multiset the value type is the same as the key type[.](#unord.req.general-7.sentence-1) For unordered_map andunordered_multimap it is pair[.](#unord.req.general-7.sentence-2) [8](#unord.req.general-8) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4187) For unordered containers where the value type is the same as the key type, both iterator and const_iterator are constant iterators[.](#unord.req.general-8.sentence-1) It is unspecified whether or not iterator andconst_iterator are the same type[.](#unord.req.general-8.sentence-2) [*Note [2](#unord.req.general-note-2)*: iterator and const_iterator have identical semantics in this case, and iterator is convertible toconst_iterator[.](#unord.req.general-8.sentence-3) Users can avoid violating the one-definition rule by always using const_iterator in their function parameter lists[.](#unord.req.general-8.sentence-4) — *end note*] [9](#unord.req.general-9) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4199) The elements of an unordered associative container are organized into*buckets*[.](#unord.req.general-9.sentence-1) Keys with the same hash code appear in the same bucket[.](#unord.req.general-9.sentence-2) The number of buckets is automatically increased as elements are added to an unordered associative container, so that the average number of elements per bucket is kept below a bound[.](#unord.req.general-9.sentence-3) Rehashing invalidates iterators, changes ordering between elements, and changes which buckets elements appear in, but does not invalidate pointers or references to elements[.](#unord.req.general-9.sentence-4) For unordered_multiset andunordered_multimap, rehashing preserves the relative ordering of equivalent elements[.](#unord.req.general-9.sentence-5) [10](#unord.req.general-10) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4213) In this subclause, - [(10.1)](#unord.req.general-10.1) X denotes an unordered associative container class, - [(10.2)](#unord.req.general-10.2) a denotes a value of type X, - [(10.3)](#unord.req.general-10.3) a2 denotes a value of a type with nodes compatible with type X (Table [75](#tab:container.node.compat "Table 75: Container types with compatible nodes")), - [(10.4)](#unord.req.general-10.4) b denotes a value of type X or const X, - [(10.5)](#unord.req.general-10.5) a_uniq denotes a value of type X when X supports unique keys, - [(10.6)](#unord.req.general-10.6) a_eq denotes a value of type X when X supports equivalent keys, - [(10.7)](#unord.req.general-10.7) a_tran denotes a value of type X or const X when the [*qualified-id*](expr.prim.id.qual#nt:qualified-id "7.5.5.3 Qualified names [expr.prim.id.qual]")*s*X​::​key_equal​::​is_transparent and X​::​hasher​::​is_transparent are both valid and denote types ([[temp.deduct]](temp.deduct "13.10.3 Template argument deduction")), - [(10.8)](#unord.req.general-10.8) i and j denote input iterators that refer to value_type, - [(10.9)](#unord.req.general-10.9) [i, j) denotes a valid range, - [(10.10)](#unord.req.general-10.10) rg denotes a value of a type R that models [*container-compatible-range*](#concept:container-compatible-range "23.2.2.1 Introduction [container.intro.reqmts]"), - [(10.11)](#unord.req.general-10.11) p and q2 denote valid constant iterators to a, - [(10.12)](#unord.req.general-10.12) q and q1 denote valid dereferenceable constant iterators to a, - [(10.13)](#unord.req.general-10.13) r denotes a valid dereferenceable iterator to a, - [(10.14)](#unord.req.general-10.14) [q1, q2) denotes a valid range in a, - [(10.15)](#unord.req.general-10.15) il denotes a value of type initializer_list, - [(10.16)](#unord.req.general-10.16) t denotes a value of type X​::​value_type, - [(10.17)](#unord.req.general-10.17) k denotes a value of type key_type, - [(10.18)](#unord.req.general-10.18) hf denotes a value of type hasher or const hasher, - [(10.19)](#unord.req.general-10.19) eq denotes a value of type key_equal or const key_equal, - [(10.20)](#unord.req.general-10.20) ke is a value such that * [(10.20.1)](#unord.req.general-10.20.1) eq(r1, ke) == eq(ke, r1), * [(10.20.2)](#unord.req.general-10.20.2) hf(r1) == hf(ke) if eq(r1, ke) is true, and * [(10.20.3)](#unord.req.general-10.20.3) if any two of eq(r1, ke), eq(r2, ke), and eq(r1, r2) are true, then all three are true, where r1 and r2 are keys of elements in a_tran, - [(10.21)](#unord.req.general-10.21) kx is a value such that * [(10.21.1)](#unord.req.general-10.21.1) eq(r1, kx) == eq(kx, r1), * [(10.21.2)](#unord.req.general-10.21.2) hf(r1) == hf(kx) if eq(r1, kx) is true, * [(10.21.3)](#unord.req.general-10.21.3) if any two of eq(r1, kx), eq(r2, kx), and eq(r1, r2) are true, then all three are true, and * [(10.21.4)](#unord.req.general-10.21.4) kx is not convertible to either iterator or const_iterator, where r1 and r2 are keys of elements in a_tran, - [(10.22)](#unord.req.general-10.22) n denotes a value of type size_type, - [(10.23)](#unord.req.general-10.23) z denotes a value of type float, and - [(10.24)](#unord.req.general-10.24) nh denotes an rvalue of type X​::​node_type[.](#unord.req.general-10.sentence-1) [11](#unord.req.general-11) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4300) A type X meets the [*unordered associative container*](#def:container,unordered_associative "23.2.8.1 General [unord.req.general]") requirements if X meets all the requirements of an allocator-aware container ([[container.alloc.reqmts]](#container.alloc.reqmts "23.2.2.5 Allocator-aware containers")) and the following types, statements, and expressions are well-formed and have the specified semantics, except that for unordered_map and unordered_multimap, the requirements placed on value_type in [[container.reqmts]](#container.reqmts "23.2.2.2 Container requirements") apply instead to key_type and mapped_type[.](#unord.req.general-11.sentence-1) [*Note [3](#unord.req.general-note-3)*: For example, key_type and mapped_type sometimes need to be *Cpp17CopyAssignable* even though the associated value_type,pair, is not *Cpp17CopyAssignable*[.](#unord.req.general-11.sentence-2) — *end note*] [🔗](#lib:key_type,unordered_associative_containers) `typename X::key_type ` [12](#unord.req.general-12) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4333) *Result*: Key[.](#unord.req.general-12.sentence-1) [🔗](#lib:mapped_type,unordered_associative_containers) `typename X::mapped_type ` [13](#unord.req.general-13) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4344) *Result*: T[.](#unord.req.general-13.sentence-1) [14](#unord.req.general-14) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4348) *Remarks*: For unordered_map and unordered_multimap only[.](#unord.req.general-14.sentence-1) [🔗](#lib:value_type,unordered_associative_containers) `typename X::value_type ` [15](#unord.req.general-15) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4359) *Result*: Key for unordered_set and unordered_multiset only;pair for unordered_map and unordered_multimap only[.](#unord.req.general-15.sentence-1) [16](#unord.req.general-16) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4365) *Preconditions*: value_type is *Cpp17Erasable* from X[.](#unord.req.general-16.sentence-1) [🔗](#lib:hasher,unordered_associative_containers) `typename X::hasher ` [17](#unord.req.general-17) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4376) *Result*: Hash[.](#unord.req.general-17.sentence-1) [18](#unord.req.general-18) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4380) *Preconditions*: Hash is a unary function object type such that the expression hf(k) has type size_t[.](#unord.req.general-18.sentence-1) [🔗](#lib:key_equal,unordered_associative_containers) `typename X::key_equal ` [19](#unord.req.general-19) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4392) *Result*: Pred[.](#unord.req.general-19.sentence-1) [20](#unord.req.general-20) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4396) *Preconditions*: Pred meets the *Cpp17CopyConstructible* requirements[.](#unord.req.general-20.sentence-1) Pred is a binary predicate that takes two arguments of type Key[.](#unord.req.general-20.sentence-2) Pred is an equivalence relation[.](#unord.req.general-20.sentence-3) [🔗](#lib:local_iterator,unordered_associative_containers) `typename X::local_iterator ` [21](#unord.req.general-21) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4409) *Result*: An iterator type whose category, value type, difference type, and pointer and reference types are the same as X​::​iterator's[.](#unord.req.general-21.sentence-1) [*Note [4](#unord.req.general-note-4)*: A local_iterator object can be used to iterate through a single bucket, but cannot be used to iterate across buckets[.](#unord.req.general-21.sentence-2) — *end note*] [🔗](#lib:const_local_iterator,unordered_associative_containers) `typename X::const_local_iterator ` [22](#unord.req.general-22) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4426) *Result*: An iterator type whose category, value type, difference type, and pointer and reference types are the same as X​::​const_iterator's[.](#unord.req.general-22.sentence-1) [*Note [5](#unord.req.general-note-5)*: A const_local_iterator object can be used to iterate through a single bucket, but cannot be used to iterate across buckets[.](#unord.req.general-22.sentence-2) — *end note*] [🔗](#lib:node_type,unordered_associative_containers) `typename X::node_type ` [23](#unord.req.general-23) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4444) *Result*: A specialization of a *node-handle* class template ([[container.node]](#container.node "23.2.5 Node handles")), such that the public nested types are the same types as the corresponding types in X[.](#unord.req.general-23.sentence-1) [🔗](#lib:unordered_set,constructor) `X(n, hf, eq) ` [24](#unord.req.general-24) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4460) *Effects*: Constructs an empty container with at least n buckets, using hf as the hash function andeq as the key equality predicate[.](#unord.req.general-24.sentence-1) [25](#unord.req.general-25) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4466) *Complexity*: O(n) [🔗](#unord.req.general-itemdecl:10) `X(n, hf) ` [26](#unord.req.general-26) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4476) *Preconditions*: key_equal meets the *Cpp17DefaultConstructible* requirements[.](#unord.req.general-26.sentence-1) [27](#unord.req.general-27) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4480) *Effects*: Constructs an empty container with at least n buckets, using hf as the hash function andkey_equal() as the key equality predicate[.](#unord.req.general-27.sentence-1) [28](#unord.req.general-28) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4486) *Complexity*: O(n) [🔗](#unord.req.general-itemdecl:11) `X(n) ` [29](#unord.req.general-29) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4496) *Preconditions*: hasher and key_equal meet the *Cpp17DefaultConstructible* requirements[.](#unord.req.general-29.sentence-1) [30](#unord.req.general-30) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4501) *Effects*: Constructs an empty container with at least n buckets, using hasher() as the hash function andkey_equal() as the key equality predicate[.](#unord.req.general-30.sentence-1) [31](#unord.req.general-31) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4507) *Complexity*: O(n) [🔗](#unord.req.general-itemdecl:12) `X a = X(); X a; ` [32](#unord.req.general-32) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4518) *Preconditions*: hasher and key_equal meet the *Cpp17DefaultConstructible* requirements[.](#unord.req.general-32.sentence-1) [33](#unord.req.general-33) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4523) *Effects*: Constructs an empty container with an unspecified number of buckets, using hasher() as the hash function andkey_equal() as the key equality predicate[.](#unord.req.general-33.sentence-1) [34](#unord.req.general-34) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4529) *Complexity*: Constant[.](#unord.req.general-34.sentence-1) [🔗](#unord.req.general-itemdecl:13) `X(i, j, n, hf, eq) ` [35](#unord.req.general-35) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4539) *Preconditions*: value_type is*Cpp17EmplaceConstructible* into X from *i[.](#unord.req.general-35.sentence-1) [36](#unord.req.general-36) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4544) *Effects*: Constructs an empty container with at least n buckets, using hf as the hash function andeq as the key equality predicate, and inserts elements from [i, j) into it[.](#unord.req.general-36.sentence-1) [37](#unord.req.general-37) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4551) *Complexity*: Average case O(N) (N is distance(i, j)), worst case O(N2)[.](#unord.req.general-37.sentence-1) [🔗](#unord.req.general-itemdecl:14) `X(i, j, n, hf) ` [38](#unord.req.general-38) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4561) *Preconditions*: key_equal meets the *Cpp17DefaultConstructible* requirements[.](#unord.req.general-38.sentence-1) value_type is*Cpp17EmplaceConstructible* into X from *i[.](#unord.req.general-38.sentence-2) [39](#unord.req.general-39) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4567) *Effects*: Constructs an empty container with at least n buckets, using hf as the hash function andkey_equal() as the key equality predicate, and inserts elements from [i, j) into it[.](#unord.req.general-39.sentence-1) [40](#unord.req.general-40) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4574) *Complexity*: Average case O(N) (N is distance(i, j)), worst case O(N2)[.](#unord.req.general-40.sentence-1) [🔗](#unord.req.general-itemdecl:15) `X(i, j, n) ` [41](#unord.req.general-41) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4584) *Preconditions*: hasher and key_equal meet the *Cpp17DefaultConstructible* requirements[.](#unord.req.general-41.sentence-1) value_type is*Cpp17EmplaceConstructible* into X from *i[.](#unord.req.general-41.sentence-2) [42](#unord.req.general-42) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4591) *Effects*: Constructs an empty container with at least n buckets, using hasher() as the hash function andkey_equal() as the key equality predicate, and inserts elements from [i, j) into it[.](#unord.req.general-42.sentence-1) [43](#unord.req.general-43) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4598) *Complexity*: Average case O(N) (N is distance(i, j)), worst case O(N2)[.](#unord.req.general-43.sentence-1) [🔗](#unord.req.general-itemdecl:16) `X(i, j) ` [44](#unord.req.general-44) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4608) *Preconditions*: hasher and key_equal meet the *Cpp17DefaultConstructible* requirements[.](#unord.req.general-44.sentence-1) value_type is*Cpp17EmplaceConstructible* into X from *i[.](#unord.req.general-44.sentence-2) [45](#unord.req.general-45) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4615) *Effects*: Constructs an empty container with an unspecified number of buckets, using hasher() as the hash function andkey_equal() as the key equality predicate, and inserts elements from [i, j) into it[.](#unord.req.general-45.sentence-1) [46](#unord.req.general-46) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4622) *Complexity*: Average case O(N) (N is distance(i, j)), worst case O(N2)[.](#unord.req.general-46.sentence-1) [🔗](#unord.req.general-itemdecl:17) `X(from_range, rg, n, hf, eq) ` [47](#unord.req.general-47) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4632) *Preconditions*: value_type is*Cpp17EmplaceConstructible* into X from *ranges​::​begin(rg)[.](#unord.req.general-47.sentence-1) [48](#unord.req.general-48) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4638) *Effects*: Constructs an empty container with at least n buckets, using hf as the hash function andeq as the key equality predicate, and inserts elements from rg into it[.](#unord.req.general-48.sentence-1) [49](#unord.req.general-49) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4645) *Complexity*: Average case O(N) (N is ranges​::​distance(rg)), worst case O(N2)[.](#unord.req.general-49.sentence-1) [🔗](#unord.req.general-itemdecl:18) `X(from_range, rg, n, hf) ` [50](#unord.req.general-50) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4656) *Preconditions*: key_equal meets the *Cpp17DefaultConstructible* requirements[.](#unord.req.general-50.sentence-1) value_type is*Cpp17EmplaceConstructible* into X from *ranges​::​begin(rg)[.](#unord.req.general-50.sentence-2) [51](#unord.req.general-51) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4663) *Effects*: Constructs an empty container with at least n buckets, using hf as the hash function andkey_equal() as the key equality predicate, and inserts elements from rg into it[.](#unord.req.general-51.sentence-1) [52](#unord.req.general-52) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4670) *Complexity*: Average case O(N) (N is ranges​::​distance(rg)), worst case O(N2)[.](#unord.req.general-52.sentence-1) [🔗](#unord.req.general-itemdecl:19) `X(from_range, rg, n) ` [53](#unord.req.general-53) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4681) *Preconditions*: hasher and key_equal meet the *Cpp17DefaultConstructible* requirements[.](#unord.req.general-53.sentence-1) value_type is*Cpp17EmplaceConstructible* into X from *ranges​::​begin(rg)[.](#unord.req.general-53.sentence-2) [54](#unord.req.general-54) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4689) *Effects*: Constructs an empty container with at least n buckets, using hasher() as the hash function andkey_equal() as the key equality predicate, and inserts elements from rg into it[.](#unord.req.general-54.sentence-1) [55](#unord.req.general-55) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4696) *Complexity*: Average case O(N) (N is ranges​::​distance(rg)), worst case O(N2)[.](#unord.req.general-55.sentence-1) [🔗](#unord.req.general-itemdecl:20) `X(from_range, rg) ` [56](#unord.req.general-56) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4707) *Preconditions*: hasher and key_equal meet the *Cpp17DefaultConstructible* requirements[.](#unord.req.general-56.sentence-1) value_type is*Cpp17EmplaceConstructible* into X from *ranges​::​begin(rg)[.](#unord.req.general-56.sentence-2) [57](#unord.req.general-57) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4715) *Effects*: Constructs an empty container with an unspecified number of buckets, using hasher() as the hash function andkey_equal() as the key equality predicate, and inserts elements from rg into it[.](#unord.req.general-57.sentence-1) [58](#unord.req.general-58) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4722) *Complexity*: Average case O(N) (N is ranges​::​distance(rg)), worst case O(N2)[.](#unord.req.general-58.sentence-1) [🔗](#unord.req.general-itemdecl:21) `X(il) ` [59](#unord.req.general-59) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4733) *Effects*: Equivalent to X(il.begin(), il.end())[.](#unord.req.general-59.sentence-1) [🔗](#unord.req.general-itemdecl:22) `X(il, n) ` [60](#unord.req.general-60) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4743) *Effects*: Equivalent to X(il.begin(), il.end(), n)[.](#unord.req.general-60.sentence-1) [🔗](#unord.req.general-itemdecl:23) `X(il, n, hf) ` [61](#unord.req.general-61) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4753) *Effects*: Equivalent to X(il.begin(), il.end(), n, hf)[.](#unord.req.general-61.sentence-1) [🔗](#unord.req.general-itemdecl:24) `X(il, n, hf, eq) ` [62](#unord.req.general-62) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4763) *Effects*: Equivalent to X(il.begin(), il.end(), n, hf, eq)[.](#unord.req.general-62.sentence-1) [🔗](#unord.req.general-itemdecl:25) `X(b) ` [63](#unord.req.general-63) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4773) *Effects*: In addition to the container requirements ([[container.reqmts]](#container.reqmts "23.2.2.2 Container requirements")), copies the hash function, predicate, and maximum load factor[.](#unord.req.general-63.sentence-1) [64](#unord.req.general-64) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4778) *Complexity*: Average case linear in b.size(), worst case quadratic[.](#unord.req.general-64.sentence-1) [🔗](#unord.req.general-itemdecl:26) `a = b ` [65](#unord.req.general-65) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4788) *Result*: X& [66](#unord.req.general-66) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4792) *Effects*: In addition to the container requirements, copies the hash function, predicate, and maximum load factor[.](#unord.req.general-66.sentence-1) [67](#unord.req.general-67) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4797) *Complexity*: Average case linear in b.size(), worst case quadratic[.](#unord.req.general-67.sentence-1) [🔗](#unord.req.general-itemdecl:27) `a = il ` [68](#unord.req.general-68) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4807) *Result*: X& [69](#unord.req.general-69) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4811) *Preconditions*: value_type is *Cpp17CopyInsertable* into X and *Cpp17CopyAssignable*[.](#unord.req.general-69.sentence-1) [70](#unord.req.general-70) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4816) *Effects*: Assigns the range [il.begin(), il.end()) into a[.](#unord.req.general-70.sentence-1) All existing elements of a are either assigned to or destroyed[.](#unord.req.general-70.sentence-2) [71](#unord.req.general-71) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4821) *Complexity*: Average case linear in il.size(), worst case quadratic[.](#unord.req.general-71.sentence-1) [🔗](#lib:hash_function,unordered_associative_containers) `b.hash_function() ` [72](#unord.req.general-72) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4832) *Result*: hasher [73](#unord.req.general-73) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4836) *Returns*: b's hash function[.](#unord.req.general-73.sentence-1) [74](#unord.req.general-74) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4840) *Complexity*: Constant[.](#unord.req.general-74.sentence-1) [🔗](#lib:key_eq,unordered_associative_containers) `b.key_eq() ` [75](#unord.req.general-75) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4851) *Result*: key_equal [76](#unord.req.general-76) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4855) *Returns*: b's key equality predicate[.](#unord.req.general-76.sentence-1) [77](#unord.req.general-77) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4859) *Complexity*: Constant[.](#unord.req.general-77.sentence-1) [🔗](#lib:emplace,unordered_associative_containers) `a_uniq.emplace(args) ` [78](#unord.req.general-78) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4870) *Result*: pair [79](#unord.req.general-79) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4874) *Preconditions*: value_type is*Cpp17EmplaceConstructible* into X from args[.](#unord.req.general-79.sentence-1) [80](#unord.req.general-80) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4879) *Effects*: Inserts a value_type object t constructed with std​::​forward(args)... if and only if there is no element in the container with key equivalent to the key of t[.](#unord.req.general-80.sentence-1) [81](#unord.req.general-81) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4886) *Returns*: The bool component of the returned pair is true if and only if the insertion takes place, and the iterator component of the pair points to the element with key equivalent to the key of t[.](#unord.req.general-81.sentence-1) [82](#unord.req.general-82) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4893) *Complexity*: Average case O(1), worst case O(a_uniq.size())[.](#unord.req.general-82.sentence-1) [🔗](#lib:emplace,unordered_associative_containers_) `a_eq.emplace(args) ` [83](#unord.req.general-83) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4904) *Result*: iterator [84](#unord.req.general-84) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4908) *Preconditions*: value_type is*Cpp17EmplaceConstructible* into X from args[.](#unord.req.general-84.sentence-1) [85](#unord.req.general-85) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4913) *Effects*: Inserts a value_type object t constructed with std​::​forward(args)...[.](#unord.req.general-85.sentence-1) [86](#unord.req.general-86) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4918) *Returns*: An iterator pointing to the newly inserted element[.](#unord.req.general-86.sentence-1) [87](#unord.req.general-87) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4922) *Complexity*: Average case O(1), worst case O(a_eq.size())[.](#unord.req.general-87.sentence-1) [🔗](#lib:emplace_hint,unordered_associative_containers) `a.emplace_hint(p, args) ` [88](#unord.req.general-88) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4933) *Result*: iterator [89](#unord.req.general-89) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4937) *Effects*: Equivalent to a.emplace(std​::​forward(args)...), except that the const_iterator p is a hint pointing to where the search should start[.](#unord.req.general-89.sentence-1) Implementations are permitted to ignore the hint[.](#unord.req.general-89.sentence-2) [90](#unord.req.general-90) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4944) *Returns*: The iterator returned by emplace[.](#unord.req.general-90.sentence-1) [🔗](#lib:insert,unordered_associative_containers) `a_uniq.insert(t) ` [91](#unord.req.general-91) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4955) *Result*: pair [92](#unord.req.general-92) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4959) *Preconditions*: If t is a non-const rvalue,value_type is *Cpp17MoveInsertable* into X; otherwise, value_type is *Cpp17CopyInsertable* into X[.](#unord.req.general-92.sentence-1) [93](#unord.req.general-93) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4965) *Effects*: Inserts t if and only if there is no element in the container with key equivalent to the key of t[.](#unord.req.general-93.sentence-1) [94](#unord.req.general-94) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4970) *Returns*: The bool component of the returned pair indicates whether the insertion takes place, and the iterator component points to the element with key equivalent to the key of t[.](#unord.req.general-94.sentence-1) [95](#unord.req.general-95) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4977) *Complexity*: Average case O(1), worst case O(a_uniq.size())[.](#unord.req.general-95.sentence-1) [🔗](#lib:insert,unordered_associative_containers_) `a_eq.insert(t) ` [96](#unord.req.general-96) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4988) *Result*: iterator [97](#unord.req.general-97) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4992) *Preconditions*: If t is a non-const rvalue,value_type is *Cpp17MoveInsertable* into X; otherwise, value_type is *Cpp17CopyInsertable* into X[.](#unord.req.general-97.sentence-1) [98](#unord.req.general-98) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4998) *Effects*: Inserts t[.](#unord.req.general-98.sentence-1) [99](#unord.req.general-99) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5002) *Returns*: An iterator pointing to the newly inserted element[.](#unord.req.general-99.sentence-1) [100](#unord.req.general-100) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5006) *Complexity*: Average case O(1), worst case O(a_eq.size())[.](#unord.req.general-100.sentence-1) [🔗](#lib:insert,unordered_associative_containers__) `a.insert(p, t) ` [101](#unord.req.general-101) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5017) *Result*: iterator [102](#unord.req.general-102) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5021) *Preconditions*: If t is a non-const rvalue,value_type is *Cpp17MoveInsertable* into X; otherwise, value_type is *Cpp17CopyInsertable* into X[.](#unord.req.general-102.sentence-1) [103](#unord.req.general-103) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5027) *Effects*: Equivalent to a.insert(t)[.](#unord.req.general-103.sentence-1) The iterator p is a hint pointing to where the search should start[.](#unord.req.general-103.sentence-2) Implementations are permitted to ignore the hint[.](#unord.req.general-103.sentence-3) [104](#unord.req.general-104) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5033) *Returns*: An iterator pointing to the element with the key equivalent to that of t[.](#unord.req.general-104.sentence-1) [105](#unord.req.general-105) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5038) *Complexity*: Average case O(1), worst case O(a.size())[.](#unord.req.general-105.sentence-1) [🔗](#lib:insert,unordered_associative_containers___) `a.insert(i, j) ` [106](#unord.req.general-106) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5049) *Result*: void [107](#unord.req.general-107) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5053) *Preconditions*: value_type is*Cpp17EmplaceConstructible* into X from *i[.](#unord.req.general-107.sentence-1) Neither i nor j are iterators into a[.](#unord.req.general-107.sentence-2) [108](#unord.req.general-108) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5059) *Effects*: Equivalent to a.insert(t) for each element in [i, j)[.](#unord.req.general-108.sentence-1) [109](#unord.req.general-109) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5063) *Complexity*: Average case O(N), where N is distance(i, j), worst case O(N(a.size()+1))[.](#unord.req.general-109.sentence-1) [🔗](#lib:insert_range,unordered_associative_containers) `a.insert_range(rg) ` [110](#unord.req.general-110) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5075) *Result*: void [111](#unord.req.general-111) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5079) *Preconditions*: value_type is*Cpp17EmplaceConstructible* into X from *ranges​::​begin(rg)[.](#unord.req.general-111.sentence-1) rg and a do not overlap[.](#unord.req.general-111.sentence-2) [112](#unord.req.general-112) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5086) *Effects*: Equivalent to a.insert(t) for each element t in rg[.](#unord.req.general-112.sentence-1) [113](#unord.req.general-113) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5090) *Complexity*: Average case O(N), where N is ranges​::​distance(rg), worst case O(N(a.size()+1))[.](#unord.req.general-113.sentence-1) [🔗](#lib:insert,unordered_associative_containers____) `a.insert(il) ` [114](#unord.req.general-114) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5102) *Effects*: Equivalent to a.insert(il.begin(), il.end())[.](#unord.req.general-114.sentence-1) [🔗](#lib:insert,unordered_associative_containers_____) `a_uniq.insert(nh) ` [115](#unord.req.general-115) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5113) *Result*: insert_return_type [116](#unord.req.general-116) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5117) *Preconditions*: nh is empty ora_uniq.get_allocator() == nh.get_allocator() is true[.](#unord.req.general-116.sentence-1) [117](#unord.req.general-117) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5122) *Effects*: If nh is empty, has no effect[.](#unord.req.general-117.sentence-1) Otherwise, inserts the element owned by nh if and only if there is no element in the container with a key equivalent to nh.key()[.](#unord.req.general-117.sentence-2) [118](#unord.req.general-118) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5128) *Postconditions*: If nh is empty, inserted is false,position is end(), and node is empty[.](#unord.req.general-118.sentence-1) Otherwise if the insertion took place, inserted is true,position points to the inserted element, and node is empty; if the insertion failed, inserted is false,node has the previous value of nh, and position points to an element with a key equivalent to nh.key()[.](#unord.req.general-118.sentence-2) [119](#unord.req.general-119) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5138) *Complexity*: Average case O(1), worst case O(a_uniq.size())[.](#unord.req.general-119.sentence-1) [🔗](#lib:insert,unordered_associative_containers______) `a_eq.insert(nh) ` [120](#unord.req.general-120) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5149) *Result*: iterator [121](#unord.req.general-121) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5153) *Preconditions*: nh is empty ora_eq.get_allocator() == nh.get_allocator() is true[.](#unord.req.general-121.sentence-1) [122](#unord.req.general-122) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5158) *Effects*: If nh is empty, has no effect and returns a_eq.end()[.](#unord.req.general-122.sentence-1) Otherwise, inserts the element owned by nh and returns an iterator pointing to the newly inserted element[.](#unord.req.general-122.sentence-2) [123](#unord.req.general-123) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5164) *Postconditions*: nh is empty[.](#unord.req.general-123.sentence-1) [124](#unord.req.general-124) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5168) *Complexity*: Average case O(1), worst case O(a_eq.size())[.](#unord.req.general-124.sentence-1) [🔗](#lib:insert,unordered_associative_containers_______) `a.insert(q, nh) ` [125](#unord.req.general-125) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5179) *Result*: iterator [126](#unord.req.general-126) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5183) *Preconditions*: nh is empty ora.get_allocator() == nh.get_allocator() is true[.](#unord.req.general-126.sentence-1) [127](#unord.req.general-127) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5188) *Effects*: If nh is empty, has no effect and returns a.end()[.](#unord.req.general-127.sentence-1) Otherwise, inserts the element owned by nh if and only if there is no element with key equivalent to nh.key() in containers with unique keys; always inserts the element owned by nh in containers with equivalent keys[.](#unord.req.general-127.sentence-2) The iterator q is a hint pointing to where the search should start[.](#unord.req.general-127.sentence-3) Implementations are permitted to ignore the hint[.](#unord.req.general-127.sentence-4) [128](#unord.req.general-128) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5199) *Postconditions*: nh is empty if insertion succeeds, unchanged if insertion fails[.](#unord.req.general-128.sentence-1) [129](#unord.req.general-129) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5203) *Returns*: An iterator pointing to the element with key equivalent to nh.key()[.](#unord.req.general-129.sentence-1) [130](#unord.req.general-130) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5207) *Complexity*: Average case O(1), worst case O(a.size())[.](#unord.req.general-130.sentence-1) [🔗](#lib:extract,unordered_associative_containers) `a.extract(k) ` [131](#unord.req.general-131) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5218) *Result*: node_type [132](#unord.req.general-132) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5222) *Effects*: Removes an element in the container with key equivalent to k[.](#unord.req.general-132.sentence-1) [133](#unord.req.general-133) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5226) *Returns*: A node_type owning the element if found, otherwise an empty node_type[.](#unord.req.general-133.sentence-1) [134](#unord.req.general-134) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5231) *Complexity*: Average case O(1), worst case O(a.size())[.](#unord.req.general-134.sentence-1) [🔗](#lib:extract,unordered_associative_containers_) `a_tran.extract(kx) ` [135](#unord.req.general-135) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5242) *Result*: node_type [136](#unord.req.general-136) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5246) *Effects*: Removes an element in the container with key equivalent to kx[.](#unord.req.general-136.sentence-1) [137](#unord.req.general-137) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5250) *Returns*: A node_type owning the element if found, otherwise an empty node_type[.](#unord.req.general-137.sentence-1) [138](#unord.req.general-138) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5255) *Complexity*: Average case O(1), worst case O(a_tran.size())[.](#unord.req.general-138.sentence-1) [🔗](#lib:extract,unordered_associative_containers__) `a.extract(q) ` [139](#unord.req.general-139) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5266) *Result*: node_type [140](#unord.req.general-140) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5270) *Effects*: Removes the element pointed to by q[.](#unord.req.general-140.sentence-1) [141](#unord.req.general-141) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5274) *Returns*: A node_type owning that element[.](#unord.req.general-141.sentence-1) [142](#unord.req.general-142) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5278) *Complexity*: Average case O(1), worst case O(a.size())[.](#unord.req.general-142.sentence-1) [🔗](#lib:merge,unordered_associative_containers) `a.merge(a2) ` [143](#unord.req.general-143) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5289) *Result*: void [144](#unord.req.general-144) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5293) *Preconditions*: a.get_allocator() == a2.get_allocator()[.](#unord.req.general-144.sentence-1) [145](#unord.req.general-145) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5297) *Effects*: Attempts to extract each element in a2 and insert it into a using the hash function and key equality predicate of a[.](#unord.req.general-145.sentence-1) In containers with unique keys, if there is an element in a with key equivalent to the key of an element from a2, then that element is not extracted from a2[.](#unord.req.general-145.sentence-2) [146](#unord.req.general-146) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5305) *Postconditions*: Pointers and references to the transferred elements of a2 refer to those same elements but as members of a[.](#unord.req.general-146.sentence-1) Iterators referring to the transferred elements and all iterators referring to a will be invalidated, but iterators to elements remaining in a2 will remain valid[.](#unord.req.general-146.sentence-2) [147](#unord.req.general-147) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5313) *Complexity*: Average case O(N), where N is a2.size(), worst case O(N*a.size() + N)[.](#unord.req.general-147.sentence-1) [🔗](#lib:erase,unordered_associative_containers) `a.erase(k) ` [148](#unord.req.general-148) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5325) *Result*: size_type [149](#unord.req.general-149) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5329) *Effects*: Erases all elements with key equivalent to k[.](#unord.req.general-149.sentence-1) [150](#unord.req.general-150) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5333) *Returns*: The number of elements erased[.](#unord.req.general-150.sentence-1) [151](#unord.req.general-151) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5337) *Complexity*: Average case O(a.count(k)), worst case O(a.size())[.](#unord.req.general-151.sentence-1) [🔗](#lib:erase,unordered_associative_containers_) `a_tran.erase(kx) ` [152](#unord.req.general-152) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5348) *Result*: size_type [153](#unord.req.general-153) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5352) *Effects*: Erases all elements with key equivalent to kx[.](#unord.req.general-153.sentence-1) [154](#unord.req.general-154) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5356) *Returns*: The number of elements erased[.](#unord.req.general-154.sentence-1) [155](#unord.req.general-155) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5360) *Complexity*: Average case O(a_tran.count(kx)), worst case O(a_tran.size())[.](#unord.req.general-155.sentence-1) [🔗](#lib:erase,unordered_associative_containers__) `a.erase(q) ` [156](#unord.req.general-156) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5372) *Result*: iterator [157](#unord.req.general-157) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5376) *Effects*: Erases the element pointed to by q[.](#unord.req.general-157.sentence-1) [158](#unord.req.general-158) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5380) *Returns*: The iterator immediately following q prior to the erasure[.](#unord.req.general-158.sentence-1) [159](#unord.req.general-159) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5384) *Complexity*: Average case O(1), worst case O(a.size())[.](#unord.req.general-159.sentence-1) [🔗](#lib:erase,unordered_associative_containers___) `a.erase(r) ` [160](#unord.req.general-160) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5395) *Result*: iterator [161](#unord.req.general-161) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5399) *Effects*: Erases the element pointed to by r[.](#unord.req.general-161.sentence-1) [162](#unord.req.general-162) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5403) *Returns*: The iterator immediately following r prior to the erasure[.](#unord.req.general-162.sentence-1) [163](#unord.req.general-163) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5407) *Complexity*: Average case O(1), worst case O(a.size())[.](#unord.req.general-163.sentence-1) [🔗](#lib:erase,unordered_associative_containers____) `a.erase(q1, q2) ` [164](#unord.req.general-164) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5418) *Result*: iterator [165](#unord.req.general-165) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5422) *Effects*: Erases all elements in the range [q1, q2)[.](#unord.req.general-165.sentence-1) [166](#unord.req.general-166) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5426) *Returns*: The iterator immediately following the erased elements prior to the erasure[.](#unord.req.general-166.sentence-1) [167](#unord.req.general-167) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5430) *Complexity*: Average case linear in distance(q1, q2), worst case O(a.size())[.](#unord.req.general-167.sentence-1) [🔗](#lib:clear,unordered_associative_containers) `a.clear() ` [168](#unord.req.general-168) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5442) *Result*: void [169](#unord.req.general-169) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5446) *Effects*: Erases all elements in the container[.](#unord.req.general-169.sentence-1) [170](#unord.req.general-170) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5450) *Postconditions*: a.empty() is true[.](#unord.req.general-170.sentence-1) [171](#unord.req.general-171) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5454) *Complexity*: Linear in a.size()[.](#unord.req.general-171.sentence-1) [🔗](#lib:find,unordered_associative_containers) `b.find(k) ` [172](#unord.req.general-172) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5465) *Result*: iterator; const_iterator for constant b[.](#unord.req.general-172.sentence-1) [173](#unord.req.general-173) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5469) *Returns*: An iterator pointing to an element with key equivalent to k, orb.end() if no such element exists[.](#unord.req.general-173.sentence-1) [174](#unord.req.general-174) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5474) *Complexity*: Average case O(1), worst case O(b.size())[.](#unord.req.general-174.sentence-1) [🔗](#lib:find,unordered_associative_containers_) `a_tran.find(ke) ` [175](#unord.req.general-175) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5485) *Result*: iterator; const_iterator for constant a_tran[.](#unord.req.general-175.sentence-1) [176](#unord.req.general-176) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5489) *Returns*: An iterator pointing to an element with key equivalent to ke, ora_tran.end() if no such element exists[.](#unord.req.general-176.sentence-1) [177](#unord.req.general-177) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5494) *Complexity*: Average case O(1), worst case O(a_tran.size())[.](#unord.req.general-177.sentence-1) [🔗](#lib:count,unordered_associative_containers) `b.count(k) ` [178](#unord.req.general-178) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5505) *Result*: size_type [179](#unord.req.general-179) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5509) *Returns*: The number of elements with key equivalent to k[.](#unord.req.general-179.sentence-1) [180](#unord.req.general-180) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5513) *Complexity*: Average case O(b.count(k)), worst case O(b.size())[.](#unord.req.general-180.sentence-1) [🔗](#lib:count,unordered_associative_containers_) `a_tran.count(ke) ` [181](#unord.req.general-181) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5524) *Result*: size_type [182](#unord.req.general-182) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5528) *Returns*: The number of elements with key equivalent to ke[.](#unord.req.general-182.sentence-1) [183](#unord.req.general-183) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5532) *Complexity*: Average case O(a_tran.count(ke)), worst case O(a_tran.size())[.](#unord.req.general-183.sentence-1) [🔗](#lib:contains,unordered_associative_containers) `b.contains(k) ` [184](#unord.req.general-184) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5544) *Effects*: Equivalent to b.find(k) != b.end()[.](#unord.req.general-184.sentence-1) [🔗](#lib:contains,unordered_associative_containers_) `a_tran.contains(ke) ` [185](#unord.req.general-185) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5555) *Effects*: Equivalent to a_tran.find(ke) != a_tran.end()[.](#unord.req.general-185.sentence-1) [🔗](#lib:equal_range,unordered_associative_containers) `b.equal_range(k) ` [186](#unord.req.general-186) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5566) *Result*: pair;pair for constant b[.](#unord.req.general-186.sentence-1) [187](#unord.req.general-187) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5571) *Returns*: A range containing all elements with keys equivalent to k[.](#unord.req.general-187.sentence-1) Returns make_pair(b.end(), b.end()) if no such elements exist[.](#unord.req.general-187.sentence-2) [188](#unord.req.general-188) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5576) *Complexity*: Average case O(b.count(k)), worst case O(b.size())[.](#unord.req.general-188.sentence-1) [🔗](#lib:equal_range,unordered_associative_containers_) `a_tran.equal_range(ke) ` [189](#unord.req.general-189) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5587) *Result*: pair;pair for constant a_tran[.](#unord.req.general-189.sentence-1) [190](#unord.req.general-190) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5592) *Returns*: A range containing all elements with keys equivalent to ke[.](#unord.req.general-190.sentence-1) Returns make_pair(a_tran.end(), a_tran.end()) if no such elements exist[.](#unord.req.general-190.sentence-2) [191](#unord.req.general-191) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5597) *Complexity*: Average case O(a_tran.count(ke)), worst case O(a_tran.size())[.](#unord.req.general-191.sentence-1) [🔗](#lib:bucket_count,unordered_associative_containers) `b.bucket_count() ` [192](#unord.req.general-192) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5609) *Result*: size_type [193](#unord.req.general-193) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5613) *Returns*: The number of buckets that b contains[.](#unord.req.general-193.sentence-1) [194](#unord.req.general-194) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5617) *Complexity*: Constant[.](#unord.req.general-194.sentence-1) [🔗](#lib:max_bucket_count,unordered_associative_containers) `b.max_bucket_count() ` [195](#unord.req.general-195) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5628) *Result*: size_type [196](#unord.req.general-196) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5632) *Returns*: An upper bound on the number of buckets that b can ever contain[.](#unord.req.general-196.sentence-1) [197](#unord.req.general-197) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5636) *Complexity*: Constant[.](#unord.req.general-197.sentence-1) [🔗](#lib:bucket,unordered_associative_containers) `b.bucket(k) ` [198](#unord.req.general-198) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5647) *Result*: size_type [199](#unord.req.general-199) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5651) *Preconditions*: b.bucket_count() > 0[.](#unord.req.general-199.sentence-1) [200](#unord.req.general-200) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5655) *Returns*: The index of the bucket in which elements with keys equivalent to k would be found, if any such element existed[.](#unord.req.general-200.sentence-1) The return value is in the range [0, b.bucket_count())[.](#unord.req.general-200.sentence-2) [201](#unord.req.general-201) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5662) *Complexity*: Constant[.](#unord.req.general-201.sentence-1) [🔗](#lib:bucket,unordered_associative_containers_) `a_tran.bucket(ke) ` [202](#unord.req.general-202) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5673) *Result*: size_type [203](#unord.req.general-203) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5677) *Preconditions*: a_tran.bucket_count() > 0[.](#unord.req.general-203.sentence-1) [204](#unord.req.general-204) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5681) *Postconditions*: The return value is in the range [0, a_tran.bucket_count())[.](#unord.req.general-204.sentence-1) [205](#unord.req.general-205) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5685) *Returns*: The index of the bucket in which elements with keys equivalent to ke would be found, if any such element existed[.](#unord.req.general-205.sentence-1) [206](#unord.req.general-206) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5691) *Complexity*: Constant[.](#unord.req.general-206.sentence-1) [🔗](#lib:bucket_size,unordered_associative_containers) `b.bucket_size(n) ` [207](#unord.req.general-207) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5702) *Result*: size_type [208](#unord.req.general-208) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5706) *Preconditions*: n shall be in the range [0, b.bucket_count())[.](#unord.req.general-208.sentence-1) [209](#unord.req.general-209) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5710) *Returns*: The number of elements in the nth bucket[.](#unord.req.general-209.sentence-1) [210](#unord.req.general-210) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5714) *Complexity*: O(b.bucket_size(n)) [🔗](#lib:begin,unordered_associative_containers) `b.begin(n) ` [211](#unord.req.general-211) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5725) *Result*: local_iterator; const_local_iterator for constant b[.](#unord.req.general-211.sentence-1) [212](#unord.req.general-212) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5729) *Preconditions*: n is in the range [0, b.bucket_count())[.](#unord.req.general-212.sentence-1) [213](#unord.req.general-213) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5733) *Returns*: An iterator referring to the first element in the bucket[.](#unord.req.general-213.sentence-1) If the bucket is empty, then b.begin(n) == b.end(n)[.](#unord.req.general-213.sentence-2) [214](#unord.req.general-214) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5738) *Complexity*: Constant[.](#unord.req.general-214.sentence-1) [🔗](#lib:end,unordered_associative_containers) `b.end(n) ` [215](#unord.req.general-215) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5749) *Result*: local_iterator; const_local_iterator for constant b[.](#unord.req.general-215.sentence-1) [216](#unord.req.general-216) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5753) *Preconditions*: n is in the range [0, b.bucket_count())[.](#unord.req.general-216.sentence-1) [217](#unord.req.general-217) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5757) *Returns*: An iterator which is the past-the-end value for the bucket[.](#unord.req.general-217.sentence-1) [218](#unord.req.general-218) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5761) *Complexity*: Constant[.](#unord.req.general-218.sentence-1) [🔗](#lib:cbegin,unordered_associative_containers) `b.cbegin(n) ` [219](#unord.req.general-219) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5772) *Result*: const_local_iterator [220](#unord.req.general-220) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5776) *Preconditions*: n shall be in the range [0, b.bucket_count())[.](#unord.req.general-220.sentence-1) [221](#unord.req.general-221) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5780) *Returns*: An iterator referring to the first element in the bucket[.](#unord.req.general-221.sentence-1) If the bucket is empty, then b.cbegin(n) == b.cend(n)[.](#unord.req.general-221.sentence-2) [222](#unord.req.general-222) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5785) *Complexity*: Constant[.](#unord.req.general-222.sentence-1) [🔗](#lib:cend,unordered_associative_containers) `b.cend(n) ` [223](#unord.req.general-223) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5796) *Result*: const_local_iterator [224](#unord.req.general-224) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5800) *Preconditions*: n is in the range [0, b.bucket_count())[.](#unord.req.general-224.sentence-1) [225](#unord.req.general-225) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5804) *Returns*: An iterator which is the past-the-end value for the bucket[.](#unord.req.general-225.sentence-1) [226](#unord.req.general-226) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5808) *Complexity*: Constant[.](#unord.req.general-226.sentence-1) [🔗](#lib:load_factor,unordered_associative_containers) `b.load_factor() ` [227](#unord.req.general-227) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5819) *Result*: float [228](#unord.req.general-228) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5823) *Returns*: The average number of elements per bucket[.](#unord.req.general-228.sentence-1) [229](#unord.req.general-229) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5827) *Complexity*: Constant[.](#unord.req.general-229.sentence-1) [🔗](#lib:max_load_factor,unordered_associative_containers) `b.max_load_factor() ` [230](#unord.req.general-230) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5838) *Result*: float [231](#unord.req.general-231) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5842) *Returns*: A positive number that the container attempts to keep the load factor less than or equal to[.](#unord.req.general-231.sentence-1) The container automatically increases the number of buckets as necessary to keep the load factor below this number[.](#unord.req.general-231.sentence-2) [232](#unord.req.general-232) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5849) *Complexity*: Constant[.](#unord.req.general-232.sentence-1) [🔗](#lib:max_load_factor,unordered_associative_containers_) `a.max_load_factor(z) ` [233](#unord.req.general-233) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5860) *Result*: void [234](#unord.req.general-234) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5864) *Preconditions*: z is positive[.](#unord.req.general-234.sentence-1) May change the container's maximum load factor, using z as a hint[.](#unord.req.general-234.sentence-2) [235](#unord.req.general-235) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5869) *Complexity*: Constant[.](#unord.req.general-235.sentence-1) [🔗](#lib:rehash,unordered_associative_containers) `a.rehash(n) ` [236](#unord.req.general-236) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5880) *Result*: void [237](#unord.req.general-237) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5884) *Postconditions*: a.bucket_count() >= a.size() / a.max_load_factor() anda.bucket_count() >= n[.](#unord.req.general-237.sentence-1) [238](#unord.req.general-238) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5889) *Complexity*: Average case linear in a.size(), worst case quadratic[.](#unord.req.general-238.sentence-1) [🔗](#lib:reserve,unordered_associative_containers) `a.reserve(n) ` [239](#unord.req.general-239) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5900) *Effects*: Equivalent to a.rehash(ceil(n / a.max_load_factor()))[.](#unord.req.general-239.sentence-1) [240](#unord.req.general-240) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5905) Two unordered containers a and b compare equal ifa.size() == b.size() and, for every equivalent-key group [Ea1, Ea2) obtained from a.equal_range(Ea1), there exists an equivalent-key group [Eb1, Eb2) obtained from b.equal_range(Ea1), such thatis_permutation(Ea1, Ea2, Eb1, Eb2) returns true[.](#unord.req.general-240.sentence-1) Forunordered_set and unordered_map, the complexity ofoperator== (i.e., the number of calls to the == operator of the value_type, to the predicate returned by key_eq(), and to the hasher returned by hash_function()) is proportional toN in the average case and to N2 in the worst case, where N isa.size()[.](#unord.req.general-240.sentence-2) For unordered_multiset and unordered_multimap, the complexity of operator== is proportional to ∑E2i in the average case and to N2 in the worst case, where N is a.size(), and Ei is the size of the ith equivalent-key group in a[.](#unord.req.general-240.sentence-3) However, if the respective elements of each corresponding pair of equivalent-key groups Eai and Ebi are arranged in the same order (as is commonly the case, e.g., if a and b are unmodified copies of the same container), then the average-case complexity forunordered_multiset and unordered_multimap becomes proportional to N (but worst-case complexity remains O(N2), e.g., for a pathologically bad hash function)[.](#unord.req.general-240.sentence-4) The behavior of a program that usesoperator== or operator!= on unordered containers is undefined unless the Pred function object has the same behavior for both containers and the equality comparison function for Key is a refinement[194](#footnote-194 "Equality comparison is a refinement of partitioning if no two objects that compare equal fall into different partitions.") of the partition into equivalent-key groups produced by Pred[.](#unord.req.general-240.sentence-5) [241](#unord.req.general-241) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5939) The iterator types iterator and const_iterator of an unordered associative container are of at least the forward iterator category[.](#unord.req.general-241.sentence-1) For unordered associative containers where the key type and value type are the same, both iterator andconst_iterator are constant iterators[.](#unord.req.general-241.sentence-2) [242](#unord.req.general-242) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5947) The insert, insert_range, and emplace members shall not affect the validity of references to container elements, but may invalidate all iterators to the container[.](#unord.req.general-242.sentence-1) The erase members shall invalidate only iterators and references to the erased elements, and preserve the relative order of the elements that are not erased[.](#unord.req.general-242.sentence-2) [243](#unord.req.general-243) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5956) The insert, insert_range, and emplace members shall not affect the validity of iterators if(N + n) <= z * B, where N is the number of elements in the container prior to the insert operation, n is the number of elements inserted, B is the container's bucket count, andz is the container's maximum load factor[.](#unord.req.general-243.sentence-1) [244](#unord.req.general-244) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5966) The extract members invalidate only iterators to the removed element, and preserve the relative order of the elements that are not erased; pointers and references to the removed element remain valid[.](#unord.req.general-244.sentence-1) However, accessing the element through such pointers and references while the element is owned by anode_type is undefined behavior[.](#unord.req.general-244.sentence-2) References and pointers to an element obtained while it is owned by a node_type are invalidated if the element is successfully inserted[.](#unord.req.general-244.sentence-3) [245](#unord.req.general-245) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5975) The member function templatesfind, count, equal_range, contains,extract, erase, and bucket shall not participate in overload resolution unless the [*qualified-id*](expr.prim.id.qual#nt:qualified-id "7.5.5.3 Qualified names [expr.prim.id.qual]")*s*Pred​::​is_transparent andHash​::​is_transparent are both valid and denote types ([[temp.deduct]](temp.deduct "13.10.3 Template argument deduction"))[.](#unord.req.general-245.sentence-1) Additionally, the member function templates extract and erase shall not participate in overload resolution ifis_convertible_v || is_convertible_v is true, where K is the type substituted as the first template argument[.](#unord.req.general-245.sentence-2) [246](#unord.req.general-246) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5990) A deduction guide for an unordered associative container shall not participate in overload resolution if any of the following are true: - [(246.1)](#unord.req.general-246.1) It has an InputIterator template parameter and a type that does not qualify as an input iterator is deduced for that parameter[.](#unord.req.general-246.1.sentence-1) - [(246.2)](#unord.req.general-246.2) It has an Allocator template parameter and a type that does not qualify as an allocator is deduced for that parameter[.](#unord.req.general-246.2.sentence-1) - [(246.3)](#unord.req.general-246.3) It has a Hash template parameter and an integral type or a type that qualifies as an allocator is deduced for that parameter[.](#unord.req.general-246.3.sentence-1) - [(246.4)](#unord.req.general-246.4) It has a Pred template parameter and a type that qualifies as an allocator is deduced for that parameter[.](#unord.req.general-246.4.sentence-1) [194)](#footnote-194)[194)](#footnoteref-194) Equality comparison is a refinement of partitioning if no two objects that compare equal fall into different partitions[.](#footnote-194.sentence-1) #### [23.2.8.2](#unord.req.except) Exception safety guarantees [[unord.req.except]](unord.req.except) [1](#unord.req.except-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L6009) For unordered associative containers, no clear() function throws an exception[.](#unord.req.except-1.sentence-1) erase(k) does not throw an exception unless that exception is thrown by the container's Hash orPred object (if any)[.](#unord.req.except-1.sentence-2) [2](#unord.req.except-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L6017) For unordered associative containers, if an exception is thrown by any operation other than the container's hash function from within aninsert or emplace function inserting a single element, the insertion has no effect[.](#unord.req.except-2.sentence-1) [3](#unord.req.except-3) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L6023) For unordered associative containers, no swap function throws an exception unless that exception is thrown by the swap of the container'sHash or Pred object (if any)[.](#unord.req.except-3.sentence-1) [4](#unord.req.except-4) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L6028) For unordered associative containers, if an exception is thrown from within a rehash() function other than by the container's hash function or comparison function, the rehash() function has no effect[.](#unord.req.except-4.sentence-1)