This commit is contained in:
2025-10-25 03:02:53 +03:00
commit 043225d523
3416 changed files with 681196 additions and 0 deletions

View File

@@ -0,0 +1,98 @@
[deque.capacity]
# 23 Containers library [[containers]](./#containers)
## 23.3 Sequence containers [[sequences]](sequences#deque.capacity)
### 23.3.5 Class template deque [[deque]](deque#capacity)
#### 23.3.5.3 Capacity [deque.capacity]
[🔗](#lib:resize,deque)
`constexpr void resize(size_type sz);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L6722)
*Preconditions*: T is *Cpp17MoveInsertable* and *Cpp17DefaultInsertable* into deque[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L6726)
*Effects*: If sz < size(), erases the last size() - sz elements
from the sequence[.](#2.sentence-1)
Otherwise,
appends sz - size() default-inserted elements to the sequence[.](#2.sentence-2)
[🔗](#lib:resize,deque_)
`constexpr void resize(size_type sz, const T& c);
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L6739)
*Preconditions*: T is *Cpp17CopyInsertable* into deque[.](#3.sentence-1)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L6743)
*Effects*: If sz < size(), erases the last size() - sz elements
from the sequence[.](#4.sentence-1)
Otherwise,
appends sz - size() copies of c to the sequence[.](#4.sentence-2)
[🔗](#lib:shrink_to_fit,deque)
`constexpr void shrink_to_fit();
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L6756)
*Preconditions*: T is *Cpp17MoveInsertable* into deque[.](#5.sentence-1)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L6760)
*Effects*: shrink_to_fit is a non-binding request to reduce memory use
but does not change the size of the sequence[.](#6.sentence-1)
[*Note [1](#note-1)*:
The request is non-binding to allow latitude for
implementation-specific optimizations[.](#6.sentence-2)
— *end note*]
If the size is equal to the old capacity, or
if an exception is thrown other than by the move constructor
of a non-*Cpp17CopyInsertable* T,
then there are no effects[.](#6.sentence-3)
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L6773)
*Complexity*: If the size is not equal to the old capacity,
linear in the size of the sequence;
otherwise constant[.](#7.sentence-1)
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L6779)
*Remarks*: If the size is not equal to the old capacity,
then invalidates all the references, pointers, and iterators
referring to the elements in the sequence,
as well as the past-the-end iterator[.](#8.sentence-1)

113
cppdraft/deque/cons.md Normal file
View File

@@ -0,0 +1,113 @@
[deque.cons]
# 23 Containers library [[containers]](./#containers)
## 23.3 Sequence containers [[sequences]](sequences#deque.cons)
### 23.3.5 Class template deque [[deque]](deque#cons)
#### 23.3.5.2 Constructors, copy, and assignment [deque.cons]
[🔗](#lib:deque,constructor)
`constexpr explicit deque(const Allocator&);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L6624)
*Effects*: Constructs an emptydeque,
using the specified allocator[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L6630)
*Complexity*: Constant[.](#2.sentence-1)
[🔗](#lib:deque,constructor_)
`constexpr explicit deque(size_type n, const Allocator& = Allocator());
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L6641)
*Preconditions*: T is *Cpp17DefaultInsertable* into deque[.](#3.sentence-1)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L6645)
*Effects*: Constructs a deque withn default-inserted elements using the specified allocator[.](#4.sentence-1)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L6650)
*Complexity*: Linear in n[.](#5.sentence-1)
[🔗](#lib:deque,constructor__)
`constexpr deque(size_type n, const T& value, const Allocator& = Allocator());
`
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L6661)
*Preconditions*: T is *Cpp17CopyInsertable* into deque[.](#6.sentence-1)
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L6665)
*Effects*: Constructs adeque with n copies of value,
using the specified allocator[.](#7.sentence-1)
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L6672)
*Complexity*: Linear in n[.](#8.sentence-1)
[🔗](#lib:deque,constructor___)
`template<class InputIterator>
constexpr deque(InputIterator first, InputIterator last, const Allocator& = Allocator());
`
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L6684)
*Effects*: Constructs adeque equal to the range
[first, last),
using the specified allocator[.](#9.sentence-1)
[10](#10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L6692)
*Complexity*: Linear in distance(first, last)[.](#10.sentence-1)
[🔗](#lib:deque,constructor____)
`template<[container-compatible-range](container.intro.reqmts#concept:container-compatible-range "23.2.2.1Introduction[container.intro.reqmts]")<T> R>
constexpr deque(from_range_t, R&& rg, const Allocator& = Allocator());
`
[11](#11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L6704)
*Effects*: Constructs a deque with the elements of the range rg,
using the specified allocator[.](#11.sentence-1)
[12](#12)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L6709)
*Complexity*: Linear in ranges::distance(rg)[.](#12.sentence-1)

37
cppdraft/deque/erasure.md Normal file
View File

@@ -0,0 +1,37 @@
[deque.erasure]
# 23 Containers library [[containers]](./#containers)
## 23.3 Sequence containers [[sequences]](sequences#deque.erasure)
### 23.3.5 Class template deque [[deque]](deque#erasure)
#### 23.3.5.5 Erasure [deque.erasure]
[🔗](#lib:erase,deque)
`template<class T, class Allocator, class U = T>
constexpr typename deque<T, Allocator>::size_type
erase(deque<T, Allocator>& c, const U& value);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L6891)
*Effects*: Equivalent to:auto it = remove(c.begin(), c.end(), value);auto r = distance(it, c.end());
c.erase(it, c.end());return r;
[🔗](#lib:erase_if,deque)
`template<class T, class Allocator, class Predicate>
constexpr typename deque<T, Allocator>::size_type
erase_if(deque<T, Allocator>& c, Predicate pred);
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L6910)
*Effects*: Equivalent to:auto it = remove_if(c.begin(), c.end(), pred);auto r = distance(it, c.end());
c.erase(it, c.end());return r;

113
cppdraft/deque/modifiers.md Normal file
View File

@@ -0,0 +1,113 @@
[deque.modifiers]
# 23 Containers library [[containers]](./#containers)
## 23.3 Sequence containers [[sequences]](sequences#deque.modifiers)
### 23.3.5 Class template deque [[deque]](deque#modifiers)
#### 23.3.5.4 Modifiers [deque.modifiers]
[🔗](#lib:insert,deque)
`constexpr iterator insert(const_iterator position, const T& x);
constexpr iterator insert(const_iterator position, T&& x);
constexpr iterator insert(const_iterator position, size_type n, const T& x);
template<class InputIterator>
constexpr iterator insert(const_iterator position,
InputIterator first, InputIterator last);
template<[container-compatible-range](container.intro.reqmts#concept:container-compatible-range "23.2.2.1Introduction[container.intro.reqmts]")<T> R>
constexpr iterator insert_range(const_iterator position, R&& rg);
constexpr iterator insert(const_iterator position, initializer_list<T>);
template<class... Args> constexpr reference emplace_front(Args&&... args);
template<class... Args> constexpr reference emplace_back(Args&&... args);
template<class... Args> constexpr iterator emplace(const_iterator position, Args&&... args);
constexpr void push_front(const T& x);
constexpr void push_front(T&& x);
template<[container-compatible-range](container.intro.reqmts#concept:container-compatible-range "23.2.2.1Introduction[container.intro.reqmts]")<T> R>
constexpr void prepend_range(R&& rg);
constexpr void push_back(const T& x);
constexpr void push_back(T&& x);
template<[container-compatible-range](container.intro.reqmts#concept:container-compatible-range "23.2.2.1Introduction[container.intro.reqmts]")<T> R>
constexpr void append_range(R&& rg);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L6818)
*Effects*: An insertion in the middle of the deque invalidates all the iterators and
references to elements of the deque[.](#1.sentence-1)
An insertion at either end of the
deque invalidates all the iterators to the deque, but has no effect on
the validity of references to elements of the deque[.](#1.sentence-2)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L6826)
*Complexity*: The complexity is linear in the number of elements inserted plus the lesser
of the distances to the beginning and end of the deque[.](#2.sentence-1)
Inserting a single element at either the beginning or end of a deque always takes constant time
and causes a single call to a constructor ofT[.](#2.sentence-2)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L6834)
*Remarks*: If an exception is thrown other than by the
copy constructor, move constructor,
assignment operator, or move assignment operator ofT,
there are no effects[.](#3.sentence-1)
If an exception is thrown while inserting a single element at either end,
there are no effects[.](#3.sentence-2)
Otherwise, if an exception is thrown by the move constructor of a
non-*Cpp17CopyInsertable*T, the effects are unspecified[.](#3.sentence-3)
[🔗](#lib:erase,deque)
`constexpr iterator erase(const_iterator position);
constexpr iterator erase(const_iterator first, const_iterator last);
constexpr void pop_front();
constexpr void pop_back();
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L6857)
*Effects*: An erase operation that erases the last element of a deque invalidates only the past-the-end iterator
and all iterators and references to the erased elements[.](#4.sentence-1)
An erase operation that erases the first
element of a deque but not the last element invalidates only iterators
and references to the erased elements[.](#4.sentence-2)
An erase operation
that erases neither the first element nor the last element of a deque invalidates the past-the-end
iterator and all iterators and references to all the elements of the deque[.](#4.sentence-3)
[*Note [1](#note-1)*:
pop_front and pop_back are erase operations[.](#4.sentence-4)
— *end note*]
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L6869)
*Throws*: Nothing unless an exception is thrown by the assignment operator ofT[.](#5.sentence-1)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L6874)
*Complexity*: The number of calls to the destructor of T is the same as the
number of elements erased, but the number of calls to the assignment operator of T is
no more than the lesser of the number of elements before the erased elements and the number of elements after the erased elements[.](#6.sentence-1)

View File

@@ -0,0 +1,46 @@
[deque.overview]
# 23 Containers library [[containers]](./#containers)
## 23.3 Sequence containers [[sequences]](sequences#deque.overview)
### 23.3.5 Class template deque [[deque]](deque#overview)
#### 23.3.5.1 Overview [deque.overview]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L6466)
Adeque is a sequence container that supports [random access iterators](random.access.iterators "24.3.5.7Random access iterators[random.access.iterators]")[.](#1.sentence-1)
In addition, it supports constant time insert and erase operations at the beginning or the end;
insert and erase in the middle take linear time[.](#1.sentence-2)
That is, a deque is especially optimized for pushing and popping elements at the beginning and end[.](#1.sentence-3)
Storage management is handled automatically[.](#1.sentence-4)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L6476)
A deque meets all of the requirements
of a container ([[container.reqmts]](container.reqmts "23.2.2.2Container requirements")),
of a reversible container ([[container.rev.reqmts]](container.rev.reqmts "23.2.2.3Reversible container requirements")),
of an allocator-aware container ([[container.alloc.reqmts]](container.alloc.reqmts "23.2.2.5Allocator-aware containers")), and
of a sequence container,
including the optional sequence container requirements ([[sequence.reqmts]](sequence.reqmts "23.2.4Sequence containers"))[.](#2.sentence-1)
Descriptions are provided here only for operations ondeque that are not described in one of these tables
or for operations where there is additional semantic information[.](#2.sentence-2)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L6488)
The types iterator and const_iterator meet
the constexpr iterator requirements ([[iterator.requirements.general]](iterator.requirements.general "24.3.1General"))[.](#3.sentence-1)
namespace std {template<class T, class Allocator = allocator<T>>class deque {public:// typesusing value_type = T; using allocator_type = Allocator; using pointer = typename allocator_traits<Allocator>::pointer; using const_pointer = typename allocator_traits<Allocator>::const_pointer; using reference = value_type&; using const_reference = const value_type&; using size_type = *implementation-defined*; // see [[container.requirements]](container.requirements "23.2Requirements")using difference_type = *implementation-defined*; // see [[container.requirements]](container.requirements "23.2Requirements")using iterator = *implementation-defined*; // see [[container.requirements]](container.requirements "23.2Requirements")using const_iterator = *implementation-defined*; // see [[container.requirements]](container.requirements "23.2Requirements")using reverse_iterator = std::reverse_iterator<iterator>; using const_reverse_iterator = std::reverse_iterator<const_iterator>; // [[deque.cons]](deque.cons "23.3.5.2Constructors, copy, and assignment"), construct/copy/destroyconstexpr deque() : deque(Allocator()) { }constexpr explicit deque(const Allocator&); constexpr explicit deque(size_type n, const Allocator& = Allocator()); constexpr deque(size_type n, const T& value, const Allocator& = Allocator()); template<class InputIterator>constexpr deque(InputIterator first, InputIterator last, const Allocator& = Allocator()); template<[*container-compatible-range*](container.intro.reqmts#concept:container-compatible-range "23.2.2.1Introduction[container.intro.reqmts]")<T> R>constexpr deque(from_range_t, R&& rg, const Allocator& = Allocator()); constexpr deque(const deque& x); constexpr deque(deque&&); constexpr deque(const deque&, const type_identity_t<Allocator>&); constexpr deque(deque&&, const type_identity_t<Allocator>&); constexpr deque(initializer_list<T>, const Allocator& = Allocator()); constexpr ~deque(); constexpr deque& operator=(const deque& x); constexpr deque& operator=(deque&& x)noexcept(allocator_traits<Allocator>::is_always_equal::value); constexpr deque& operator=(initializer_list<T>); template<class InputIterator>constexpr void assign(InputIterator first, InputIterator last); template<[*container-compatible-range*](container.intro.reqmts#concept:container-compatible-range "23.2.2.1Introduction[container.intro.reqmts]")<T> R>constexpr void assign_range(R&& rg); constexpr void assign(size_type n, const T& t); constexpr void assign(initializer_list<T>); constexpr allocator_type get_allocator() const noexcept; // iteratorsconstexpr iterator begin() noexcept; constexpr const_iterator begin() const noexcept; constexpr iterator end() noexcept; constexpr const_iterator end() const noexcept; constexpr reverse_iterator rbegin() noexcept; constexpr const_reverse_iterator rbegin() const noexcept; constexpr reverse_iterator rend() noexcept; constexpr const_reverse_iterator rend() const noexcept; constexpr const_iterator cbegin() const noexcept; constexpr const_iterator cend() const noexcept; constexpr const_reverse_iterator crbegin() const noexcept; constexpr const_reverse_iterator crend() const noexcept; // [[deque.capacity]](deque.capacity "23.3.5.3Capacity"), capacityconstexpr bool empty() const noexcept; constexpr size_type size() const noexcept; constexpr size_type max_size() const noexcept; constexpr void resize(size_type sz); constexpr void resize(size_type sz, const T& c); constexpr void shrink_to_fit(); // element accessconstexpr reference operator[](size_type n); constexpr const_reference operator[](size_type n) const; constexpr reference at(size_type n); constexpr const_reference at(size_type n) const; constexpr reference front(); constexpr const_reference front() const; constexpr reference back(); constexpr const_reference back() const; // [[deque.modifiers]](deque.modifiers "23.3.5.4Modifiers"), modifierstemplate<class... Args> constexpr reference emplace_front(Args&&... args); template<class... Args> constexpr reference emplace_back(Args&&... args); template<class... Args> constexpr iterator emplace(const_iterator position, Args&&... args); constexpr void push_front(const T& x); constexpr void push_front(T&& x); template<[*container-compatible-range*](container.intro.reqmts#concept:container-compatible-range "23.2.2.1Introduction[container.intro.reqmts]")<T> R>constexpr void prepend_range(R&& rg); constexpr void push_back(const T& x); constexpr void push_back(T&& x); template<[*container-compatible-range*](container.intro.reqmts#concept:container-compatible-range "23.2.2.1Introduction[container.intro.reqmts]")<T> R>constexpr void append_range(R&& rg); constexpr iterator insert(const_iterator position, const T& x); constexpr iterator insert(const_iterator position, T&& x); constexpr iterator insert(const_iterator position, size_type n, const T& x); template<class InputIterator>constexpr iterator insert(const_iterator position,
InputIterator first, InputIterator last); template<[*container-compatible-range*](container.intro.reqmts#concept:container-compatible-range "23.2.2.1Introduction[container.intro.reqmts]")<T> R>constexpr iterator insert_range(const_iterator position, R&& rg); constexpr iterator insert(const_iterator position, initializer_list<T>); constexpr void pop_front(); constexpr void pop_back(); constexpr iterator erase(const_iterator position); constexpr iterator erase(const_iterator first, const_iterator last); constexpr void swap(deque&)noexcept(allocator_traits<Allocator>::is_always_equal::value); constexpr void clear() noexcept; }; template<class InputIterator, class Allocator = allocator<*iter-value-type*<InputIterator>>> deque(InputIterator, InputIterator, Allocator = Allocator())-> deque<*iter-value-type*<InputIterator>, Allocator>; template<ranges::[input_range](range.refinements#concept:input_range "25.4.6Other range refinements[range.refinements]") R, class Allocator = allocator<ranges::range_value_t<R>>> deque(from_range_t, R&&, Allocator = Allocator())-> deque<ranges::range_value_t<R>, Allocator>;}

13
cppdraft/deque/syn.md Normal file
View File

@@ -0,0 +1,13 @@
[deque.syn]
# 23 Containers library [[containers]](./#containers)
## 23.3 Sequence containers [[sequences]](sequences#deque.syn)
### 23.3.4 Header <deque> synopsis [deque.syn]
[🔗](#header:%3cdeque%3e)
#include <compare> // see [[compare.syn]](compare.syn "17.12.1Header <compare> synopsis")#include <initializer_list> // see [[initializer.list.syn]](initializer.list.syn "17.11.2Header <initializer_­list> synopsis")namespace std {// [[deque]](deque "23.3.5Class template deque"), class template dequetemplate<class T, class Allocator = allocator<T>> class deque; template<class T, class Allocator>constexpr bool operator==(const deque<T, Allocator>& x, const deque<T, Allocator>& y); template<class T, class Allocator>constexpr *synth-three-way-result*<T> operator<=>(const deque<T, Allocator>& x, const deque<T, Allocator>& y); template<class T, class Allocator>constexpr void swap(deque<T, Allocator>& x, deque<T, Allocator>& y)noexcept(noexcept(x.swap(y))); // [[deque.erasure]](deque.erasure "23.3.5.5Erasure"), erasuretemplate<class T, class Allocator, class U = T>constexpr typename deque<T, Allocator>::size_type
erase(deque<T, Allocator>& c, const U& value); template<class T, class Allocator, class Predicate>constexpr typename deque<T, Allocator>::size_type
erase_if(deque<T, Allocator>& c, Predicate pred); namespace pmr {template<class T>using deque = std::deque<T, polymorphic_allocator<T>>; }}