[sequence.reqmts] # 23 Containers library [[containers]](./#containers) ## 23.2 Requirements [[container.requirements]](container.requirements#sequence.reqmts) ### 23.2.4 Sequence containers [sequence.reqmts] [1](#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[.](#1.sentence-1) The library provides the following basic kinds of sequence containers:vector, inplace_vector,forward_list, list, and deque[.](#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[.](#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)[.](#1.sentence-4) [2](#2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1332) In this subclause, - [(2.1)](#2.1) X denotes a sequence container class, - [(2.2)](#2.2) a denotes a value of type X containing elements of type T, - [(2.3)](#2.3) u denotes the name of a variable being declared, - [(2.4)](#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)](#2.5) i and j denote iterators that meet the *Cpp17InputIterator* requirements and refer to elements implicitly convertible to value_type, - [(2.6)](#2.6) [i, j) denotes a valid range, - [(2.7)](#2.7) rg denotes a value of a type R that models [*container-compatible-range*](container.intro.reqmts#concept:container-compatible-range "23.2.2.1 Introduction [container.intro.reqmts]"), - [(2.8)](#2.8) il designates an object of type initializer_list, - [(2.9)](#2.9) n denotes a value of type X​::​size_type, - [(2.10)](#2.10) p denotes a valid constant iterator to a, - [(2.11)](#2.11) q denotes a valid dereferenceable constant iterator to a, - [(2.12)](#2.12) [q1, q2) denotes a valid range of constant iterators in a, - [(2.13)](#2.13) t denotes an lvalue or a const rvalue of X​::​value_type, and - [(2.14)](#2.14) rv denotes a non-const rvalue of X​::​value_type[.](#2.14.sentence-1) - [(2.15)](#2.15) Args denotes a template parameter pack; - [(2.16)](#2.16) args denotes a function parameter pack with the pattern Args&&[.](#2.16.sentence-1) [3](#3) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1375) The complexities of the expressions are sequence dependent[.](#3.sentence-1) [4](#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[.](#4.sentence-1) [🔗](#itemdecl:1) `X u(n, t); ` [5](#5) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1398) *Preconditions*: T is *Cpp17CopyInsertable* into X[.](#5.sentence-1) [6](#6) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1402) *Effects*: Constructs a sequence container with n copies of t[.](#6.sentence-1) [7](#7) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1406) *Postconditions*: distance(u.begin(), u.end()) == n is true[.](#7.sentence-1) [🔗](#itemdecl:2) `X u(i, j); ` [8](#8) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1416) *Preconditions*: T is *Cpp17EmplaceConstructible* into X from *i[.](#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[.](#8.sentence-2) [9](#9) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1424) *Effects*: Constructs a sequence container equal to the range [i, j)[.](#9.sentence-1) Each iterator in the range [i, j) is dereferenced exactly once[.](#9.sentence-2) [10](#10) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1429) *Postconditions*: distance(u.begin(), u.end()) == distance(i, j) is true[.](#10.sentence-1) [🔗](#itemdecl:3) `X(from_range, rg) ` [11](#11) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1439) *Preconditions*: T is *Cpp17EmplaceConstructible* into X from *ranges​::​begin(rg)[.](#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[.](#11.sentence-2) [12](#12) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1451) *Effects*: Constructs a sequence container equal to the range rg[.](#12.sentence-1) Each iterator in the range rg is dereferenced exactly once[.](#12.sentence-2) [13](#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[.](#13.sentence-1) [14](#14) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1462) *Postconditions*: distance(begin(), end()) == ranges​::​distance(rg) is true[.](#14.sentence-1) [🔗](#itemdecl:4) `X(il) ` [15](#15) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1472) *Effects*: Equivalent to X(il.begin(), il.end())[.](#15.sentence-1) [🔗](#itemdecl:5) `a = il ` [16](#16) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1482) *Result*: X&[.](#16.sentence-1) [17](#17) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1486) *Preconditions*: T is *Cpp17CopyInsertable* into X and*Cpp17CopyAssignable*[.](#17.sentence-1) [18](#18) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1491) *Effects*: Assigns the range [il.begin(), il.end()) into a[.](#18.sentence-1) All existing elements of a are either assigned to or destroyed[.](#18.sentence-2) [19](#19) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1496) *Returns*: *this[.](#19.sentence-1) [🔗](#lib:emplace,containers) `a.emplace(p, args) ` [20](#20) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1507) *Result*: iterator[.](#20.sentence-1) [21](#21) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1511) *Preconditions*: T is *Cpp17EmplaceConstructible* into X from args[.](#21.sentence-1) For vector, inplace_vector, and deque,T is also *Cpp17MoveInsertable* into X and*Cpp17MoveAssignable*[.](#21.sentence-2) [22](#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[.](#22.sentence-1) [*Note [1](#note-1)*: args can directly or indirectly refer to a value in a[.](#22.sentence-2) — *end note*] [23](#23) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1527) *Returns*: An iterator that points to the new element[.](#23.sentence-1) [🔗](#lib:insert,containers) `a.insert(p, t) ` [24](#24) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1538) *Result*: iterator[.](#24.sentence-1) [25](#25) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1542) *Preconditions*: T is *Cpp17CopyInsertable* into X[.](#25.sentence-1) For vector, inplace_vector, and deque,T is also *Cpp17CopyAssignable*[.](#25.sentence-2) [26](#26) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1548) *Effects*: Inserts a copy of t before p[.](#26.sentence-1) [27](#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[.](#27.sentence-1) [🔗](#itemdecl:8) `a.insert(p, rv) ` [28](#28) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1562) *Result*: iterator[.](#28.sentence-1) [29](#29) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1566) *Preconditions*: T is *Cpp17MoveInsertable* into X[.](#29.sentence-1) For vector, inplace_vector, and deque,T is also *Cpp17MoveAssignable*[.](#29.sentence-2) [30](#30) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1572) *Effects*: Inserts a copy of rv before p[.](#30.sentence-1) [31](#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[.](#31.sentence-1) [🔗](#itemdecl:9) `a.insert(p, n, t) ` [32](#32) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1586) *Result*: iterator[.](#32.sentence-1) [33](#33) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1590) *Preconditions*: T is *Cpp17CopyInsertable* into X and *Cpp17CopyAssignable*[.](#33.sentence-1) [34](#34) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1595) *Effects*: Inserts n copies of t before p[.](#34.sentence-1) [35](#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[.](#35.sentence-1) [🔗](#itemdecl:10) `a.insert(p, i, j) ` [36](#36) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1611) *Result*: iterator[.](#36.sentence-1) [37](#37) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1615) *Preconditions*: T is *Cpp17EmplaceConstructible* into X from *i[.](#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[.](#37.sentence-2) Neither i nor j are iterators into a[.](#37.sentence-3) [38](#38) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1627) *Effects*: Inserts copies of elements in [i, j) before p[.](#38.sentence-1) Each iterator in the range [i, j) shall be dereferenced exactly once[.](#38.sentence-2) [39](#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[.](#39.sentence-1) [🔗](#lib:insert_range,containers) `a.insert_range(p, rg) ` [40](#40) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1645) *Result*: iterator[.](#40.sentence-1) [41](#41) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1649) *Preconditions*: T is *Cpp17EmplaceConstructible* into X from *ranges​::​begin(rg)[.](#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[.](#41.sentence-2) rg and a do not overlap[.](#41.sentence-3) [42](#42) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1662) *Effects*: Inserts copies of elements in rg before p[.](#42.sentence-1) Each iterator in the range rg is dereferenced exactly once[.](#42.sentence-2) [43](#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[.](#43.sentence-1) [🔗](#itemdecl:12) `a.insert(p, il) ` [44](#44) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1679) *Effects*: Equivalent to a.insert(p, il.begin(), il.end())[.](#44.sentence-1) [🔗](#lib:erase,containers) `a.erase(q) ` [45](#45) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1690) *Result*: iterator[.](#45.sentence-1) [46](#46) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1694) *Preconditions*: For vector, inplace_vector, and deque,T is *Cpp17MoveAssignable*[.](#46.sentence-1) [47](#47) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1699) *Effects*: Erases the element pointed to by q[.](#47.sentence-1) [48](#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[.](#48.sentence-1) If no such element exists, a.end() is returned[.](#48.sentence-2) [🔗](#itemdecl:14) `a.erase(q1, q2) ` [49](#49) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1715) *Result*: iterator[.](#49.sentence-1) [50](#50) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1719) *Preconditions*: For vector, inplace_vector, and deque,T is *Cpp17MoveAssignable*[.](#50.sentence-1) [51](#51) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1724) *Effects*: Erases the elements in the range [q1, q2)[.](#51.sentence-1) [52](#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[.](#52.sentence-1) If no such element exists, a.end() is returned[.](#52.sentence-2) [🔗](#lib:clear,containers) `a.clear() ` [53](#53) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1741) *Result*: void [54](#54) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1745) *Effects*: Destroys all elements in a[.](#54.sentence-1) Invalidates all references, pointers, and iterators referring to the elements of a and may invalidate the past-the-end iterator[.](#54.sentence-2) [55](#55) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1752) *Postconditions*: a.empty() is true[.](#55.sentence-1) [56](#56) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1756) *Complexity*: Linear[.](#56.sentence-1) [🔗](#lib:assign,containers) `a.assign(i, j) ` [57](#57) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1767) *Result*: void [58](#58) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1771) *Preconditions*: T is *Cpp17EmplaceConstructible* into X from *i and assignable from *i[.](#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[.](#58.sentence-2) Neither i nor j are iterators into a[.](#58.sentence-3) [59](#59) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1781) *Effects*: Replaces elements in a with a copy of [i, j)[.](#59.sentence-1) Invalidates all references, pointers and iterators referring to the elements of a[.](#59.sentence-2) For vector and deque, also invalidates the past-the-end iterator[.](#59.sentence-3) Each iterator in the range [i, j) is dereferenced exactly once[.](#59.sentence-4) [🔗](#lib:assign_range,containers) `a.assign_range(rg) ` [60](#60) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1797) *Result*: void [61](#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[.](#61.sentence-1) [62](#62) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1806) *Preconditions*: T is *Cpp17EmplaceConstructible* into X from *ranges​::​begin(rg)[.](#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[.](#62.sentence-2) rg and a do not overlap[.](#62.sentence-3) [63](#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[.](#63.sentence-1) Invalidates all references, pointers, and iterators referring to the elements of a[.](#63.sentence-2) For vector and deque, also invalidates the past-the-end iterator[.](#63.sentence-3) Each iterator in the range rg is dereferenced exactly once[.](#63.sentence-4) [64](#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[.](#64.sentence-1) [🔗](#itemdecl:18) `a.assign(il) ` [65](#65) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1840) *Effects*: Equivalent to a.assign(il.begin(), il.end())[.](#65.sentence-1) [🔗](#itemdecl:19) `a.assign(n, t) ` [66](#66) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1850) *Result*: void [67](#67) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1854) *Preconditions*: T is *Cpp17CopyInsertable* into X and *Cpp17CopyAssignable*[.](#67.sentence-1) t is not a reference into a[.](#67.sentence-2) [68](#68) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1860) *Effects*: Replaces elements in a with n copies of t[.](#68.sentence-1) Invalidates all references, pointers and iterators referring to the elements of a[.](#68.sentence-2) For vector and deque, also invalidates the past-the-end iterator[.](#68.sentence-3) [69](#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)](#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)](#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)](#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](#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[.](#70.sentence-1) Operations other than prepend_range and append_range are implemented so as to take amortized constant time[.](#70.sentence-2) [🔗](#itemdecl:20) `a.front() ` [71](#71) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1917) *Result*: reference; const_reference for constant a[.](#71.sentence-1) [72](#72) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1921) *Hardened preconditions*: a.empty() is false[.](#72.sentence-1) [73](#73) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1925) *Returns*: *a.begin() [74](#74) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1929) *Remarks*: Required forbasic_string,array,deque,forward_list,inplace_vector,list, andvector[.](#74.sentence-1) [🔗](#itemdecl:21) `a.back() ` [75](#75) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1946) *Result*: reference; const_reference for constant a[.](#75.sentence-1) [76](#76) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1950) *Hardened preconditions*: a.empty() is false[.](#76.sentence-1) [77](#77) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1954) *Effects*: Equivalent to:auto tmp = a.end();--tmp;return *tmp; [78](#78) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1963) *Remarks*: Required forbasic_string,array,deque,inplace_vector,list, andvector[.](#78.sentence-1) [🔗](#itemdecl:22) `a.emplace_front(args) ` [79](#79) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1979) *Result*: reference [80](#80) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1983) *Preconditions*: T is *Cpp17EmplaceConstructible* into X from args[.](#80.sentence-1) [81](#81) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1987) *Effects*: Prepends an object of type T constructed with std​::​forward(args)...[.](#81.sentence-1) [82](#82) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1992) *Returns*: a.front()[.](#82.sentence-1) [83](#83) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1996) *Remarks*: Required fordeque,forward_list, andlist[.](#83.sentence-1) [🔗](#itemdecl:23) `a.emplace_back(args) ` [84](#84) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2009) *Result*: reference [85](#85) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2013) *Preconditions*: T is *Cpp17EmplaceConstructible* into X from args[.](#85.sentence-1) For vector,T is also *Cpp17MoveInsertable* into X[.](#85.sentence-2) [86](#86) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2019) *Effects*: Appends an object of type T constructed with std​::​forward(args)...[.](#86.sentence-1) [87](#87) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2024) *Returns*: a.back()[.](#87.sentence-1) [88](#88) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2028) *Remarks*: Required fordeque,inplace_vector,list, andvector[.](#88.sentence-1) [🔗](#itemdecl:24) `a.push_front(t) ` [89](#89) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2042) *Result*: void [90](#90) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2046) *Preconditions*: T is *Cpp17CopyInsertable* into X[.](#90.sentence-1) [91](#91) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2050) *Effects*: Prepends a copy of t[.](#91.sentence-1) [92](#92) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2054) *Remarks*: Required fordeque,forward_list, andlist[.](#92.sentence-1) [🔗](#itemdecl:25) `a.push_front(rv) ` [93](#93) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2067) *Result*: void [94](#94) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2071) *Preconditions*: T is *Cpp17MoveInsertable* into X[.](#94.sentence-1) [95](#95) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2075) *Effects*: Prepends a copy of rv[.](#95.sentence-1) [96](#96) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2079) *Remarks*: Required fordeque,forward_list, andlist[.](#96.sentence-1) [🔗](#itemdecl:26) `a.prepend_range(rg) ` [97](#97) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2092) *Result*: void [98](#98) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2096) *Preconditions*: T is *Cpp17EmplaceConstructible* into X from *ranges​::​begin(rg)[.](#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[.](#98.sentence-2) [99](#99) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2107) *Effects*: Inserts copies of elements in rg before begin()[.](#99.sentence-1) Each iterator in the range rg is dereferenced exactly once[.](#99.sentence-2) [*Note [2](#note-2)*: The order of elements in rg is not reversed[.](#99.sentence-3) — *end note*] [100](#100) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2115) *Remarks*: Required fordeque,forward_list, andlist[.](#100.sentence-1) [🔗](#itemdecl:27) `a.push_back(t) ` [101](#101) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2128) *Result*: void [102](#102) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2132) *Preconditions*: T is *Cpp17CopyInsertable* into X[.](#102.sentence-1) [103](#103) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2136) *Effects*: Appends a copy of t[.](#103.sentence-1) [104](#104) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2140) *Remarks*: Required forbasic_string,deque,inplace_vector,list, andvector[.](#104.sentence-1) [🔗](#itemdecl:28) `a.push_back(rv) ` [105](#105) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2155) *Result*: void [106](#106) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2159) *Preconditions*: T is *Cpp17MoveInsertable* into X[.](#106.sentence-1) [107](#107) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2163) *Effects*: Appends a copy of rv[.](#107.sentence-1) [108](#108) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2167) *Remarks*: Required forbasic_string,deque,inplace_vector,list, andvector[.](#108.sentence-1) [🔗](#itemdecl:29) `a.append_range(rg) ` [109](#109) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2182) *Result*: void [110](#110) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2186) *Preconditions*: T is *Cpp17EmplaceConstructible* into X from *ranges​::​begin(rg)[.](#110.sentence-1) For vector,T is also*Cpp17MoveInsertable* into X[.](#110.sentence-2) [111](#111) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2194) *Effects*: Inserts copies of elements in rg before end()[.](#111.sentence-1) Each iterator in the range rg is dereferenced exactly once[.](#111.sentence-2) [112](#112) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2199) *Remarks*: Required fordeque,inplace_vector,list, andvector[.](#112.sentence-1) [🔗](#itemdecl:30) `a.pop_front() ` [113](#113) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2213) *Result*: void [114](#114) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2217) *Hardened preconditions*: a.empty() is false[.](#114.sentence-1) [115](#115) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2221) *Effects*: Destroys the first element[.](#115.sentence-1) [116](#116) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2225) *Remarks*: Required fordeque,forward_list, andlist[.](#116.sentence-1) [🔗](#itemdecl:31) `a.pop_back() ` [117](#117) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2238) *Result*: void [118](#118) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2242) *Hardened preconditions*: a.empty() is false[.](#118.sentence-1) [119](#119) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2246) *Effects*: Destroys the last element[.](#119.sentence-1) [120](#120) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2250) *Remarks*: Required forbasic_string,deque,inplace_vector,list, andvector[.](#120.sentence-1) [🔗](#itemdecl:32) `a[n] ` [121](#121) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2265) *Result*: reference; const_reference for constant a[.](#121.sentence-1) [122](#122) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2269) *Hardened preconditions*: n < a.size() is true[.](#122.sentence-1) [123](#123) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2273) *Effects*: Equivalent to: return *(a.begin() + n); [124](#124) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2277) *Remarks*: Required forbasic_string,array,deque,inplace_vector, andvector[.](#124.sentence-1) [🔗](#itemdecl:33) `a.at(n) ` [125](#125) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2292) *Result*: reference; const_reference for constant a[.](#125.sentence-1) [126](#126) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2296) *Returns*: *(a.begin() + n) [127](#127) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2300) *Throws*: out_of_range if n >= a.size()[.](#127.sentence-1) [128](#128) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2304) *Remarks*: Required forbasic_string,array,deque,inplace_vector, andvector[.](#128.sentence-1)