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

109
cppdraft/map/access.md Normal file
View File

@@ -0,0 +1,109 @@
[map.access]
# 23 Containers library [[containers]](./#containers)
## 23.4 Associative containers [[associative]](associative#map.access)
### 23.4.3 Class template map [[map]](map#access)
#### 23.4.3.3 Element access [map.access]
[🔗](#lib:operator%5b%5d,map)
`constexpr mapped_type& operator[](const key_type& x);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11815)
*Effects*: Equivalent to: return try_emplace(x).first->second;
[🔗](#lib:operator%5b%5d,map_)
`constexpr mapped_type& operator[](key_type&& x);
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11826)
*Effects*: Equivalent to: return try_emplace(std::move(x)).first->second;
[🔗](#lib:operator%5b%5d,map__)
`template<class K> constexpr mapped_type& operator[](K&& x);
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11837)
*Constraints*: The [*qualified-id*](expr.prim.id.qual#nt:qualified-id "7.5.5.3Qualified names[expr.prim.id.qual]") Compare::is_transparent is valid and denotes a type[.](#3.sentence-1)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11842)
*Effects*: Equivalent to: return try_emplace(std::forward<K>(x)).first->second;
[🔗](#lib:at,map)
`constexpr mapped_type& at(const key_type& x);
constexpr const mapped_type& at(const key_type& x) const;
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11854)
*Returns*: A reference to the mapped_type corresponding to x in *this[.](#5.sentence-1)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11858)
*Throws*: An exception object of type out_of_range if
no such element is present[.](#6.sentence-1)
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11863)
*Complexity*: Logarithmic[.](#7.sentence-1)
[🔗](#lib:at,map_)
`template<class K> constexpr mapped_type& at(const K& x);
template<class K> constexpr const mapped_type& at(const K& x) const;
`
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11875)
*Constraints*: The [*qualified-id*](expr.prim.id.qual#nt:qualified-id "7.5.5.3Qualified names[expr.prim.id.qual]") Compare::is_transparent is valid and denotes a type[.](#8.sentence-1)
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11880)
*Preconditions*: The expression find(x) is well-formed and has well-defined behavior[.](#9.sentence-1)
[10](#10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11884)
*Returns*: A reference to find(x)->second[.](#10.sentence-1)
[11](#11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11888)
*Throws*: An exception object of type out_of_range iffind(x) == end() is true[.](#11.sentence-1)
[12](#12)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11893)
*Complexity*: Logarithmic[.](#12.sentence-1)

70
cppdraft/map/cons.md Normal file
View File

@@ -0,0 +1,70 @@
[map.cons]
# 23 Containers library [[containers]](./#containers)
## 23.4 Associative containers [[associative]](associative#map.cons)
### 23.4.3 Class template map [[map]](map#cons)
#### 23.4.3.2 Constructors, copy, and assignment [map.cons]
[🔗](#lib:map,constructor)
`constexpr explicit map(const Compare& comp, const Allocator& = Allocator());
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11751)
*Effects*: Constructs an emptymap using the specified comparison object and allocator[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11757)
*Complexity*: Constant[.](#2.sentence-1)
[🔗](#lib:map,constructor_)
`template<class InputIterator>
constexpr map(InputIterator first, InputIterator last,
const Compare& comp = Compare(), const Allocator& = Allocator());
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11770)
*Effects*: Constructs an emptymap using the specified comparison object and allocator,
and inserts elements from the range
[first, last)[.](#3.sentence-1)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11778)
*Complexity*: Linear in N if the range
[first, last)
is already sorted with respect to comp and otherwise NlogN, where N is last - first[.](#4.sentence-1)
[🔗](#lib:map,constructor__)
`template<[container-compatible-range](container.intro.reqmts#concept:container-compatible-range "23.2.2.1Introduction[container.intro.reqmts]")<value_type> R>
constexpr map(from_range_t, R&& rg, const Compare& comp = Compare(),
const Allocator& = Allocator());
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11795)
*Effects*: Constructs an empty map using the specified comparison object and allocator,
and inserts elements from the range rg[.](#5.sentence-1)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11801)
*Complexity*: Linear in N if rg is already sorted with respect to comp and
otherwise NlogN, where N is ranges::distance(rg)[.](#6.sentence-1)

22
cppdraft/map/erasure.md Normal file
View File

@@ -0,0 +1,22 @@
[map.erasure]
# 23 Containers library [[containers]](./#containers)
## 23.4 Associative containers [[associative]](associative#map.erasure)
### 23.4.3 Class template map [[map]](map#erasure)
#### 23.4.3.5 Erasure [map.erasure]
[🔗](#lib:erase_if,map)
`template<class Key, class T, class Compare, class Allocator, class Predicate>
typename map<Key, T, Compare, Allocator>::size_type
constexpr erase_if(map<Key, T, Compare, Allocator>& c, Predicate pred);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L12183)
*Effects*: Equivalent to:auto original_size = c.size();for (auto i = c.begin(), last = c.end(); i != last; ) {if (pred(*i)) { i = c.erase(i); } else {++i; }}return original_size - c.size();

322
cppdraft/map/modifiers.md Normal file
View File

@@ -0,0 +1,322 @@
[map.modifiers]
# 23 Containers library [[containers]](./#containers)
## 23.4 Associative containers [[associative]](associative#map.modifiers)
### 23.4.3 Class template map [[map]](map#modifiers)
#### 23.4.3.4 Modifiers [map.modifiers]
[🔗](#lib:insert,map)
`template<class P>
constexpr pair<iterator, bool> insert(P&& x);
template<class P>
constexpr iterator insert(const_iterator position, P&& x);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11909)
*Constraints*: is_constructible_v<value_type, P&&> is true[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11913)
*Effects*: The first form is equivalent toreturn emplace(std::forward<P>(x))[.](#2.sentence-1)
The second form is
equivalent to return emplace_hint(position, std::forward<P>(x))[.](#2.sentence-2)
[🔗](#lib:try_emplace,map)
`template<class... Args>
constexpr pair<iterator, bool> try_emplace(const key_type& k, Args&&... args);
template<class... Args>
constexpr iterator try_emplace(const_iterator hint, const key_type& k, Args&&... args);
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11929)
*Preconditions*: value_type is *Cpp17EmplaceConstructible* into map from piecewise_construct, forward_as_tuple(k),forward_as_tuple(std::forward<Args>(args)...)[.](#3.sentence-1)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11935)
*Effects*: If the map already contains an element
whose key is equivalent to k,
there is no effect[.](#4.sentence-1)
Otherwise inserts an object of type value_type constructed with piecewise_construct, forward_as_tuple(k),forward_as_tuple(std::forward<Args>(args)...)[.](#4.sentence-2)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11944)
*Returns*: In the first overload,
the bool component of the returned pair is true if and only if the insertion took place[.](#5.sentence-1)
The returned iterator points to the map element
whose key is equivalent to k[.](#5.sentence-2)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11952)
*Complexity*: The same as emplace and emplace_hint,
respectively[.](#6.sentence-1)
[🔗](#lib:try_emplace,map_)
`template<class... Args>
constexpr pair<iterator, bool> try_emplace(key_type&& k, Args&&... args);
template<class... Args>
constexpr iterator try_emplace(const_iterator hint, key_type&& k, Args&&... args);
`
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11967)
*Preconditions*: value_type is *Cpp17EmplaceConstructible* into map from piecewise_construct, forward_as_tuple(std::move(k)),forward_as_tuple(std::forward<Args>(args)...)[.](#7.sentence-1)
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11973)
*Effects*: If the map already contains an element
whose key is equivalent to k,
there is no effect[.](#8.sentence-1)
Otherwise inserts an object of type value_type constructed with piecewise_construct, forward_as_tuple(std::move(k)),forward_as_tuple(std::forward<Args>(args)...)[.](#8.sentence-2)
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11982)
*Returns*: In the first overload,
the bool component of the returned pair is true if and only if the insertion took place[.](#9.sentence-1)
The returned iterator points to the map element
whose key is equivalent to k[.](#9.sentence-2)
[10](#10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11990)
*Complexity*: The same as emplace and emplace_hint,
respectively[.](#10.sentence-1)
[🔗](#lib:try_emplace,map__)
`template<class K, class... Args>
constexpr pair<iterator, bool> try_emplace(K&& k, Args&&... args);
template<class K, class... Args>
constexpr iterator try_emplace(const_iterator hint, K&& k, Args&&... args);
`
[11](#11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L12005)
*Constraints*: The [*qualified-id*](expr.prim.id.qual#nt:qualified-id "7.5.5.3Qualified names[expr.prim.id.qual]") Compare::is_transparent is valid and denotes a type[.](#11.sentence-1)
For the first overload,is_convertible_v<K&&, const_iterator> andis_convertible_v<K&&, iterator> are both false[.](#11.sentence-2)
[12](#12)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L12014)
*Preconditions*: value_type is *Cpp17EmplaceConstructible* into map frompiecewise_construct, forward_as_tuple(std::forward<K>(k)),
forward_as_tuple(std::forward<Args>(args)...)[.](#12.sentence-1)
[13](#13)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L12020)
*Effects*: If the map already contains an element whose key is equivalent to k,
there is no effect[.](#13.sentence-1)
Otherwise, let r be equal_range(k)[.](#13.sentence-2)
Constructs an object u of type value_type withpiecewise_construct, forward_as_tuple(std::forward<K>(k)),
forward_as_tuple(std::forward<Args>(args)...)[.](#13.sentence-3)
If equal_range(u.first) == r is false,
the behavior is undefined[.](#13.sentence-4)
Inserts u into *this[.](#13.sentence-5)
[14](#14)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L12032)
*Returns*: For the first overload,
the bool component of the returned pair is true if and only if the insertion took place[.](#14.sentence-1)
The returned iterator points to the map element
whose key is equivalent to k[.](#14.sentence-2)
[15](#15)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L12040)
*Complexity*: The same as emplace and emplace_hint, respectively[.](#15.sentence-1)
[🔗](#lib:insert_or_assign,map)
`template<class M>
constexpr pair<iterator, bool> insert_or_assign(const key_type& k, M&& obj);
template<class M>
constexpr iterator insert_or_assign(const_iterator hint, const key_type& k, M&& obj);
`
[16](#16)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L12054)
*Mandates*: is_assignable_v<mapped_type&, M&&> is true[.](#16.sentence-1)
[17](#17)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L12058)
*Preconditions*: value_type is *Cpp17EmplaceConstructible* into map from k, std::forward<M>(obj)[.](#17.sentence-1)
[18](#18)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L12063)
*Effects*: If the map already contains an element e whose key is equivalent to k,
assigns std::forward<M>(obj) to e.second[.](#18.sentence-1)
Otherwise inserts an object of type value_type constructed with k, std::forward<M>(obj)[.](#18.sentence-2)
[19](#19)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L12071)
*Returns*: In the first overload,
the bool component of the returned pair is true if and only if the insertion took place[.](#19.sentence-1)
The returned iterator points to the map element
whose key is equivalent to k[.](#19.sentence-2)
[20](#20)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L12079)
*Complexity*: The same as emplace and emplace_hint,
respectively[.](#20.sentence-1)
[🔗](#lib:insert_or_assign,map_)
`template<class M>
constexpr pair<iterator, bool> insert_or_assign(key_type&& k, M&& obj);
template<class M>
constexpr iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj);
`
[21](#21)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L12094)
*Mandates*: is_assignable_v<mapped_type&, M&&> is true[.](#21.sentence-1)
[22](#22)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L12098)
*Preconditions*: value_type is *Cpp17EmplaceConstructible* into map from std::move(k), std::forward<M>(obj)[.](#22.sentence-1)
[23](#23)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L12103)
*Effects*: If the map already contains an element e whose key is equivalent to k,
assigns std::forward<M>(obj) to e.second[.](#23.sentence-1)
Otherwise inserts an object of type value_type constructed with std::move(k), std::forward<M>(obj)[.](#23.sentence-2)
[24](#24)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L12111)
*Returns*: In the first overload,
the bool component of the returned pair is true if and only if the insertion took place[.](#24.sentence-1)
The returned iterator points to the map element
whose key is equivalent to k[.](#24.sentence-2)
[25](#25)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L12119)
*Complexity*: The same as emplace and emplace_hint,
respectively[.](#25.sentence-1)
[🔗](#lib:insert_or_assign,map__)
`template<class K, class M>
constexpr pair<iterator, bool> insert_or_assign(K&& k, M&& obj);
template<class K, class M>
constexpr iterator insert_or_assign(const_iterator hint, K&& k, M&& obj);
`
[26](#26)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L12134)
*Constraints*: The [*qualified-id*](expr.prim.id.qual#nt:qualified-id "7.5.5.3Qualified names[expr.prim.id.qual]") Compare::is_transparent is valid and denotes a type[.](#26.sentence-1)
[27](#27)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L12139)
*Mandates*: is_assignable_v<mapped_type&, M&&> is true[.](#27.sentence-1)
[28](#28)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L12143)
*Preconditions*: value_type is *Cpp17EmplaceConstructible* into map fromstd::forward<K>(k), std::
forward<M>(obj)[.](#28.sentence-1)
[29](#29)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L12148)
*Effects*: If the map already contains an element e whose key is equivalent to k,
assigns std::forward<M>
(obj) to e.second[.](#29.sentence-1)
Otherwise, let r be equal_range(k)[.](#29.sentence-2)
Constructs an object u of type value_type with std::forward<K>(k), std::forward<M>(obj)[.](#29.sentence-3)
If equal_range(u.first) == r is false,
the behavior is undefined[.](#29.sentence-4)
Inserts u into *this[.](#29.sentence-5)
[30](#30)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L12160)
*Returns*: For the first overload,
the bool component of the returned pair is true if and only if the insertion took place[.](#30.sentence-1)
The returned iterator points to the map element
whose key is equivalent to k[.](#30.sentence-2)
[31](#31)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L12168)
*Complexity*: The same as emplace and emplace_hint, respectively[.](#31.sentence-1)

51
cppdraft/map/overview.md Normal file

File diff suppressed because one or more lines are too long