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

130
cppdraft/vector/bool.md Normal file

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,41 @@
[vector.bool.fmt]
# 23 Containers library [[containers]](./#containers)
## 23.3 Sequence containers [[sequences]](sequences#vector.bool.fmt)
### 23.3.14 Specialization of vector for bool [[vector.bool]](vector.bool#fmt)
#### 23.3.14.2 Formatter specialization for vector<bool> [vector.bool.fmt]
[🔗](#lib:formatter)
namespace std {template<class T, class charT>requires *is-vector-bool-reference*<T>struct formatter<T, charT> {private: formatter<bool, charT> *underlying_*; // *exposition only*public:template<class ParseContext>constexpr typename ParseContext::iterator
parse(ParseContext& ctx); template<class FormatContext>typename FormatContext::iterator
format(const T& ref, FormatContext& ctx) const; };}
[🔗](#lib:parse,formatter)
`template<class ParseContext>
constexpr typename ParseContext::iterator
parse(ParseContext& ctx);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L10671)
Equivalent to: return *underlying_*.parse(ctx);
[🔗](#lib:format,formatter)
`template<class FormatContext>
typename FormatContext::iterator
format(const T& ref, FormatContext& ctx) const;
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L10683)
Equivalent to: return *underlying_*.format(ref, ctx);

File diff suppressed because one or more lines are too long

210
cppdraft/vector/capacity.md Normal file
View File

@@ -0,0 +1,210 @@
[vector.capacity]
# 23 Containers library [[containers]](./#containers)
## 23.3 Sequence containers [[sequences]](sequences#vector.capacity)
### 23.3.13 Class template vector [[vector]](vector#capacity)
#### 23.3.13.3 Capacity [vector.capacity]
[🔗](#lib:capacity,vector)
`constexpr size_type capacity() const noexcept;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L10118)
*Returns*: The total number of elements that the vector can hold
without requiring reallocation[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L10123)
*Complexity*: Constant time[.](#2.sentence-1)
[🔗](#lib:reserve,vector)
`constexpr void reserve(size_type n);
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L10134)
*Preconditions*: T is *Cpp17MoveInsertable* into vector[.](#3.sentence-1)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L10138)
*Effects*: A directive that informs avector of a planned change in size, so that it can manage the storage allocation accordingly[.](#4.sentence-1)
Afterreserve(),capacity() is greater or equal to the argument ofreserve if reallocation happens; and equal to the previous value ofcapacity() otherwise[.](#4.sentence-2)
Reallocation happens at this point if and only if the current capacity is less than the
argument ofreserve()[.](#4.sentence-3)
If an exception is thrown
other than by the move constructor of a non-*Cpp17CopyInsertable* type,
there are no effects[.](#4.sentence-4)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L10157)
*Throws*: length_error if n > max_size()[.](#5.sentence-1)[197](#footnote-197 "reserve() uses Allocator::allocate() which can throw an appropriate exception.")
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L10166)
*Complexity*: It does not change the size of the sequence and takes at most linear
time in the size of the sequence[.](#6.sentence-1)
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L10171)
*Remarks*: Reallocation invalidates all the references, pointers, and iterators
referring to the elements in the sequence, as well as the past-the-end iterator[.](#7.sentence-1)
[*Note [1](#note-1)*:
If no reallocation happens, they remain valid[.](#7.sentence-2)
— *end note*]
No reallocation shall take place during insertions that happen
after a call to reserve() until an insertion would make the size of the vector
greater than the value of capacity()[.](#7.sentence-3)
[🔗](#lib:shrink_to_fit,vector)
`constexpr void shrink_to_fit();
`
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L10190)
*Preconditions*: T is *Cpp17MoveInsertable* into vector[.](#8.sentence-1)
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L10194)
*Effects*: shrink_to_fit is a non-binding request to reducecapacity() to size()[.](#9.sentence-1)
[*Note [2](#note-2)*:
The request is non-binding to allow latitude for
implementation-specific optimizations[.](#9.sentence-2)
— *end note*]
It does not increase capacity(), but may reduce capacity() by causing reallocation[.](#9.sentence-3)
If an exception is thrown other than by the move constructor
of a non-*Cpp17CopyInsertable* T, there are no effects[.](#9.sentence-4)
[10](#10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L10207)
*Complexity*: If reallocation happens,
linear in the size of the sequence[.](#10.sentence-1)
[11](#11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L10212)
*Remarks*: Reallocation invalidates all the references, pointers, and iterators
referring to the elements in the sequence as well as the past-the-end iterator[.](#11.sentence-1)
[*Note [3](#note-3)*:
If no reallocation happens, they remain valid[.](#11.sentence-2)
— *end note*]
[🔗](#lib:swap,vector)
`constexpr void swap(vector& x)
noexcept(allocator_traits<Allocator>::propagate_on_container_swap::value ||
allocator_traits<Allocator>::is_always_equal::value);
`
[12](#12)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L10229)
*Effects*: Exchanges the contents andcapacity() of*this with that of x[.](#12.sentence-1)
[13](#13)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L10237)
*Complexity*: Constant time[.](#13.sentence-1)
[🔗](#lib:resize,vector)
`constexpr void resize(size_type sz);
`
[14](#14)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L10248)
*Preconditions*: T is*Cpp17MoveInsertable* and *Cpp17DefaultInsertable* into vector[.](#14.sentence-1)
[15](#15)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L10253)
*Effects*: If sz < size(), erases the last size() - sz elements
from the sequence[.](#15.sentence-1)
Otherwise,
appends sz - size() default-inserted elements to the sequence[.](#15.sentence-2)
[16](#16)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L10259)
*Remarks*: If an exception is thrown other than by the move constructor of a non-*Cpp17CopyInsertable*T, there are no effects[.](#16.sentence-1)
[🔗](#lib:resize,vector_)
`constexpr void resize(size_type sz, const T& c);
`
[17](#17)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L10271)
*Preconditions*: T is*Cpp17CopyInsertable* into vector[.](#17.sentence-1)
[18](#18)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L10276)
*Effects*: If sz < size(), erases the last size() - sz elements
from the sequence[.](#18.sentence-1)
Otherwise,
appends sz - size() copies of c to the sequence[.](#18.sentence-2)
[19](#19)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L10282)
*Remarks*: If an exception is thrown, there are no effects[.](#19.sentence-1)
[197)](#footnote-197)[197)](#footnoteref-197)
reserve() uses Allocator::allocate() which
can throw an appropriate exception[.](#footnote-197.sentence-1)

135
cppdraft/vector/cons.md Normal file
View File

@@ -0,0 +1,135 @@
[vector.cons]
# 23 Containers library [[containers]](./#containers)
## 23.3 Sequence containers [[sequences]](sequences#vector.cons)
### 23.3.13 Class template vector [[vector]](vector#cons)
#### 23.3.13.2 Constructors [vector.cons]
[🔗](#lib:vector,constructor)
`constexpr explicit vector(const Allocator&) noexcept;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L9992)
*Effects*: Constructs an empty vector, using the
specified allocator[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L9997)
*Complexity*: Constant[.](#2.sentence-1)
[🔗](#lib:vector,constructor_)
`constexpr explicit vector(size_type n, const Allocator& = Allocator());
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L10008)
*Preconditions*: T is *Cpp17DefaultInsertable* into vector[.](#3.sentence-1)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L10012)
*Effects*: Constructs a vector with n default-inserted elements using the specified allocator[.](#4.sentence-1)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L10017)
*Complexity*: Linear in n[.](#5.sentence-1)
[🔗](#lib:vector,constructor__)
`constexpr vector(size_type n, const T& value,
const Allocator& = Allocator());
`
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L10029)
*Preconditions*: T is*Cpp17CopyInsertable* into vector[.](#6.sentence-1)
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L10034)
*Effects*: Constructs a vector with n copies of value, using the specified allocator[.](#7.sentence-1)
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L10039)
*Complexity*: Linear in n[.](#8.sentence-1)
[🔗](#lib:vector,constructor___)
`template<class InputIterator>
constexpr vector(InputIterator first, InputIterator last,
const Allocator& = Allocator());
`
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L10052)
*Effects*: Constructs a vector 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#L10057)
*Complexity*: Makes only N calls to the copy constructor ofT (where N is the distance betweenfirst andlast)
and no reallocations ifInputIterator meets the *Cpp17ForwardIterator* requirements[.](#10.sentence-1)
It makes orderN calls to the copy constructor ofT and orderlogN reallocations if they are just input iterators[.](#10.sentence-2)
[🔗](#lib:vector,constructor____)
`template<[container-compatible-range](container.intro.reqmts#concept:container-compatible-range "23.2.2.1Introduction[container.intro.reqmts]")<T> R>
constexpr vector(from_range_t, R&& rg, const Allocator& = Allocator());
`
[11](#11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L10085)
*Effects*: Constructs a vector object 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#L10090)
*Complexity*: Initializes exactly N elements
from the results of dereferencing successive iterators of rg,
where N is ranges::distance(rg)[.](#12.sentence-1)
[13](#13)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L10096)
Performs no reallocations if:
- [(13.1)](#13.1)
R models ranges::[approximately_sized_range](range.approximately.sized#concept:approximately_sized_range "25.4.3Approximately sized ranges[range.approximately.sized]"), andranges::distance(rg) <= ranges::reserve_hint(rg) is true, or
- [(13.2)](#13.2)
R models ranges::[forward_range](range.refinements#concept:forward_range "25.4.6Other range refinements[range.refinements]") andR does not model ranges::[approximately_sized_range](range.approximately.sized#concept:approximately_sized_range "25.4.3Approximately sized ranges[range.approximately.sized]")[.](#13.sentence-1)
Otherwise, performs order logN reallocations and
order N calls to the copy or move constructor of T[.](#13.sentence-2)

30
cppdraft/vector/data.md Normal file
View File

@@ -0,0 +1,30 @@
[vector.data]
# 23 Containers library [[containers]](./#containers)
## 23.3 Sequence containers [[sequences]](sequences#vector.data)
### 23.3.13 Class template vector [[vector]](vector#data)
#### 23.3.13.4 Data [vector.data]
[🔗](#lib:data,vector)
`constexpr T* data() noexcept;
constexpr const T* data() const noexcept;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L10296)
*Returns*: A pointer such that [data(), data() + size()) is a valid range[.](#1.sentence-1)
For a
non-empty vector, data() == addressof(front()) is true[.](#1.sentence-2)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L10301)
*Complexity*: Constant time[.](#2.sentence-1)

View File

@@ -0,0 +1,37 @@
[vector.erasure]
# 23 Containers library [[containers]](./#containers)
## 23.3 Sequence containers [[sequences]](sequences#vector.erasure)
### 23.3.13 Class template vector [[vector]](vector#erasure)
#### 23.3.13.6 Erasure [vector.erasure]
[🔗](#lib:erase,vector)
`template<class T, class Allocator, class U = T>
constexpr typename vector<T, Allocator>::size_type
erase(vector<T, Allocator>& c, const U& value);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L10410)
*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,vector)
`template<class T, class Allocator, class Predicate>
constexpr typename vector<T, Allocator>::size_type
erase_if(vector<T, Allocator>& c, Predicate pred);
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L10429)
*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;

View File

@@ -0,0 +1,110 @@
[vector.modifiers]
# 23 Containers library [[containers]](./#containers)
## 23.3 Sequence containers [[sequences]](sequences#vector.modifiers)
### 23.3.13 Class template vector [[vector]](vector#modifiers)
#### 23.3.13.5 Modifiers [vector.modifiers]
[🔗](#lib:insert,vector)
`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_back(Args&&... args);
template<class... Args> constexpr iterator emplace(const_iterator position, Args&&... args);
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#L10328)
*Complexity*: If reallocation happens,
linear in the number of elements of the resulting vector;
otherwise,
linear in the number of elements inserted plus the distance
to the end of the vector[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L10336)
*Remarks*: Causes reallocation if the new size is greater than the old capacity[.](#2.sentence-1)
Reallocation invalidates all the references, pointers, and iterators
referring to the elements in the sequence, as well as the past-the-end iterator[.](#2.sentence-2)
If no reallocation happens, then
references, pointers, and iterators
before the insertion point remain valid
but those at or after the insertion point,
including the past-the-end iterator,
are invalidated[.](#2.sentence-3)
If an exception is thrown other than by
the copy constructor, move constructor,
assignment operator, or move assignment operator ofT or by any InputIterator operation,
there are no effects[.](#2.sentence-4)
If an exception is thrown while inserting a single element at the end andT is *Cpp17CopyInsertable* or is_nothrow_move_constructible_v<T> is true, there are no effects[.](#2.sentence-5)
Otherwise, if an exception is thrown by the move constructor of a non-*Cpp17CopyInsertable*T, the effects are unspecified[.](#2.sentence-6)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L10358)
For the declarations taking a range R,
performs at most one reallocation if:
- [(3.1)](#3.1)
R models ranges::[approximately_sized_range](range.approximately.sized#concept:approximately_sized_range "25.4.3Approximately sized ranges[range.approximately.sized]") andranges::distance(rg) <= ranges::reserve_hint(rg) is true, or
- [(3.2)](#3.2)
R models ranges::[forward_range](range.refinements#concept:forward_range "25.4.6Other range refinements[range.refinements]") andR does not model ranges::[approximately_sized_range](range.approximately.sized#concept:approximately_sized_range "25.4.3Approximately sized ranges[range.approximately.sized]")[.](#3.sentence-1)
For the declarations taking a pair of InputIterator,
performs at most one reallocation ifInputIterator meets the *Cpp17ForwardIterator* requirements[.](#3.sentence-2)
[🔗](#lib:erase,vector)
`constexpr iterator erase(const_iterator position);
constexpr iterator erase(const_iterator first, const_iterator last);
constexpr void pop_back();
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L10382)
*Effects*: Invalidates iterators and references at or after the point of the erase[.](#4.sentence-1)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L10386)
*Throws*: Nothing unless an exception is thrown by the
assignment operator or move assignment operator ofT[.](#5.sentence-1)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L10392)
*Complexity*: The destructor of T is called the number of times equal to the
number of the elements erased, but the assignment operator
of T is called the number of times equal to the number of
elements in the vector after the erased elements[.](#6.sentence-1)

File diff suppressed because one or more lines are too long

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

@@ -0,0 +1,13 @@
[vector.syn]
# 23 Containers library [[containers]](./#containers)
## 23.3 Sequence containers [[sequences]](sequences#vector.syn)
### 23.3.12 Header <vector> synopsis [vector.syn]
[🔗](#header:%3cvector%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 {// [[vector]](vector "23.3.13Class template vector"), class template vectortemplate<class T, class Allocator = allocator<T>> class vector; template<class T, class Allocator>constexpr bool operator==(const vector<T, Allocator>& x, const vector<T, Allocator>& y); template<class T, class Allocator>constexpr *synth-three-way-result*<T> operator<=>(const vector<T, Allocator>& x, const vector<T, Allocator>& y); template<class T, class Allocator>constexpr void swap(vector<T, Allocator>& x, vector<T, Allocator>& y)noexcept(noexcept(x.swap(y))); // [[vector.erasure]](vector.erasure "23.3.13.6Erasure"), erasuretemplate<class T, class Allocator, class U = T>constexpr typename vector<T, Allocator>::size_type
erase(vector<T, Allocator>& c, const U& value); template<class T, class Allocator, class Predicate>constexpr typename vector<T, Allocator>::size_type
erase_if(vector<T, Allocator>& c, Predicate pred); namespace pmr {template<class T>using vector = std::vector<T, polymorphic_allocator<T>>; }// [[vector.bool]](vector.bool "23.3.14Specialization of vector for bool"), specialization of vector for bool// [[vector.bool.pspc]](vector.bool.pspc "23.3.14.1Partial class template specialization vector<bool, Allocator>"), partial class template specialization vector<bool, Allocator>template<class Allocator>class vector<bool, Allocator>; template<class T>constexpr bool *is-vector-bool-reference* = *see below*; // *exposition only*// hash supporttemplate<class T> struct hash; template<class Allocator> struct hash<vector<bool, Allocator>>; // [[vector.bool.fmt]](vector.bool.fmt "23.3.14.2Formatter specialization for vector<bool>"), formatter specialization for vector<bool>template<class T, class charT> requires *is-vector-bool-reference*<T>struct formatter<T, charT>;}