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

30
cppdraft/flat/set/cons.md Normal file
View File

@@ -0,0 +1,30 @@
[flat.set.cons]
# 23 Containers library [[containers]](./#containers)
## 23.6 Container adaptors [[container.adaptors]](container.adaptors#flat.set.cons)
### 23.6.11 Class template flat_set [[flat.set]](flat.set#cons)
#### 23.6.11.3 Constructors [flat.set.cons]
[🔗](#lib:flat_set,constructor)
`constexpr explicit flat_set(container_type cont, const key_compare& comp = key_compare());
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L19167)
*Effects*: Initializes *c* with std::move(cont) and*compare* with comp,
sorts the range [begin(), end()) with respect to *compare*, and
finally erases all but the first element
from each group of consecutive equivalent elements[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L19175)
*Complexity*: Linear in N if cont is already sorted with respect to *compare* and
otherwise NlogN, where N is the value of cont.size() before this call[.](#2.sentence-1)

View File

@@ -0,0 +1,105 @@
[flat.set.cons.alloc]
# 23 Containers library [[containers]](./#containers)
## 23.6 Container adaptors [[container.adaptors]](container.adaptors#flat.set.cons.alloc)
### 23.6.11 Class template flat_set [[flat.set]](flat.set#cons.alloc)
#### 23.6.11.4 Constructors with allocators [flat.set.cons.alloc]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L19183)
The constructors in this subclause shall not participate in overload resolution
unless uses_allocator_v<container_type, Alloc> is true[.](#1.sentence-1)
[🔗](#lib:flat_set,constructor)
`template<class Alloc>
constexpr flat_set(const container_type& cont, const Alloc& a);
template<class Alloc>
constexpr flat_set(const container_type& cont, const key_compare& comp, const Alloc& a);
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L19196)
*Effects*: Equivalent toflat_set(cont) and flat_set(cont, comp), respectively,
except that *c* is constructed with
uses-allocator construction ([[allocator.uses.construction]](allocator.uses.construction "20.2.8.2Uses-allocator construction"))[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L19203)
*Complexity*: Same as flat_set(cont) and flat_set(cont, comp), respectively[.](#3.sentence-1)
[🔗](#lib:flat_set,constructor_)
`template<class Alloc>
constexpr flat_set(sorted_unique_t, const container_type& cont, const Alloc& a);
template<class Alloc>
constexpr flat_set(sorted_unique_t, const container_type& cont,
const key_compare& comp, const Alloc& a);
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L19218)
*Effects*: Equivalent toflat_set(sorted_unique, cont) andflat_set(sorted_unique, cont,
comp), respectively,
except that *c* is constructed with
uses-allocator construction ([[allocator.uses.construction]](allocator.uses.construction "20.2.8.2Uses-allocator construction"))[.](#4.sentence-1)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L19226)
*Complexity*: Linear[.](#5.sentence-1)
[🔗](#lib:flat_set,constructor__)
`template<class Alloc>
constexpr explicit flat_set(const Alloc& a);
template<class Alloc>
constexpr flat_set(const key_compare& comp, const Alloc& a);
template<class Alloc>
constexpr flat_set(const flat_set&, const Alloc& a);
template<class Alloc>
constexpr flat_set(flat_set&&, const Alloc& a);
template<class InputIterator, class Alloc>
constexpr flat_set(InputIterator first, InputIterator last, const Alloc& a);
template<class InputIterator, class Alloc>
constexpr flat_set(InputIterator first, InputIterator last, const key_compare& comp,
const Alloc& a);
template<class InputIterator, class Alloc>
constexpr flat_set(sorted_unique_t, InputIterator first, InputIterator last, const Alloc& a);
template<class InputIterator, class Alloc>
constexpr flat_set(sorted_unique_t, InputIterator first, InputIterator last,
const key_compare& comp, const Alloc& a);
template<[container-compatible-range](container.intro.reqmts#concept:container-compatible-range "23.2.2.1Introduction[container.intro.reqmts]")<value_type> R, class Alloc>
constexpr flat_set(from_range_t, R&& rg, const Alloc& a);
template<[container-compatible-range](container.intro.reqmts#concept:container-compatible-range "23.2.2.1Introduction[container.intro.reqmts]")<value_type> R, class Alloc>
constexpr flat_set(from_range_t, R&& rg, const key_compare& comp, const Alloc& a);
template<class Alloc>
constexpr flat_set(initializer_list<value_type> il, const Alloc& a);
template<class Alloc>
constexpr flat_set(initializer_list<value_type> il, const key_compare& comp, const Alloc& a);
template<class Alloc>
constexpr flat_set(sorted_unique_t, initializer_list<value_type> il, const Alloc& a);
template<class Alloc>
constexpr flat_set(sorted_unique_t, initializer_list<value_type> il,
const key_compare& comp, const Alloc& a);
`
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L19267)
*Effects*: Equivalent to the corresponding non-allocator constructors
except that *c* is constructed with
uses-allocator construction ([[allocator.uses.construction]](allocator.uses.construction "20.2.8.2Uses-allocator construction"))[.](#6.sentence-1)

15
cppdraft/flat/set/defn.md Normal file

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,56 @@
[flat.set.erasure]
# 23 Containers library [[containers]](./#containers)
## 23.6 Container adaptors [[container.adaptors]](container.adaptors#flat.set.erasure)
### 23.6.11 Class template flat_set [[flat.set]](flat.set#erasure)
#### 23.6.11.6 Erasure [flat.set.erasure]
[🔗](#lib:erase_if,flat_set)
`template<class Key, class Compare, class KeyContainer, class Predicate>
constexpr typename flat_set<Key, Compare, KeyContainer>::size_type
erase_if(flat_set<Key, Compare, KeyContainer>& c, Predicate pred);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L19444)
*Preconditions*: Key meets the *Cpp17MoveAssignable* requirements[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L19448)
*Effects*: Let E be bool(pred(as_const(e)))[.](#2.sentence-1)
Erases all elements e in c for which E holds[.](#2.sentence-2)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L19453)
*Returns*: The number of elements erased[.](#3.sentence-1)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L19457)
*Complexity*: Exactly c.size() applications of the predicate[.](#4.sentence-1)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L19461)
*Remarks*: Stable ([[algorithm.stable]](algorithm.stable "16.4.6.8Requirements for stable algorithms"))[.](#5.sentence-1)
If an invocation of erase_if exits via an exception,c is in a valid but unspecified state ([[defns.valid]](defns.valid "3.67valid but unspecified state"))[.](#5.sentence-2)
[*Note [1](#note-1)*:
c still meets its invariants, but can be empty[.](#5.sentence-3)
— *end note*]

View File

@@ -0,0 +1,175 @@
[flat.set.modifiers]
# 23 Containers library [[containers]](./#containers)
## 23.6 Container adaptors [[container.adaptors]](container.adaptors#flat.set.modifiers)
### 23.6.11 Class template flat_set [[flat.set]](flat.set#modifiers)
#### 23.6.11.5 Modifiers [flat.set.modifiers]
[🔗](#lib:insert,flat_set)
`template<class K> constexpr pair<iterator, bool> insert(K&& x);
template<class K> constexpr iterator insert(const_iterator hint, K&& x);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L19283)
*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[.](#1.sentence-1)
is_constructible_v<value_type, K> is true[.](#1.sentence-2)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L19289)
*Preconditions*: The conversion from x into value_type constructs
an object u, for which find(x) == find(u) is true[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L19294)
*Effects*: If the set already contains an element equivalent to x,*this and x are unchanged[.](#3.sentence-1)
Otherwise,
inserts a new element as if by emplace(std::forward<K>(x))[.](#3.sentence-2)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L19301)
*Returns*: In the first overload,
the bool component of the returned pair is true if and only if the insertion took place[.](#4.sentence-1)
The returned iterator points to the element
whose key is equivalent to x[.](#4.sentence-2)
[🔗](#lib:insert,flat_set_)
`template<class InputIterator>
constexpr void insert(InputIterator first, InputIterator last);
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L19317)
*Effects*: Adds elements to *c* as if by:*c*.insert(*c*.end(), first, last);
Then,
sorts the range of newly inserted elements with respect to *compare*;
merges the resulting sorted range and
the sorted range of pre-existing elements into a single sorted range; and
finally erases all but the first element
from each group of consecutive equivalent elements[.](#5.sentence-2)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L19330)
*Complexity*: N + MlogM, where N is size() before the operation andM is distance(first, last)[.](#6.sentence-1)
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L19335)
*Remarks*: Since this operation performs an in-place merge, it may allocate memory[.](#7.sentence-1)
[🔗](#lib:insert,flat_set__)
`template<class InputIterator>
constexpr void insert(sorted_unique_t, InputIterator first, InputIterator last);
`
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L19347)
*Effects*: Equivalent to insert(first, last)[.](#8.sentence-1)
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L19351)
*Complexity*: Linear[.](#9.sentence-1)
[🔗](#lib:insert_range,flat_set)
`template<[container-compatible-range](container.intro.reqmts#concept:container-compatible-range "23.2.2.1Introduction[container.intro.reqmts]")<value_type> R>
constexpr void insert_range(R&& rg);
`
[10](#10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L19363)
*Effects*: Adds elements to *c* as if by:for (const auto& e : rg) {*c*.insert(*c*.end(), e);}
Then,
sorts the range of newly inserted elements with respect to *compare*;
merges the resulting sorted range and
the sorted range of pre-existing elements into a single sorted range; and
finally erases all but the first element
from each group of consecutive equivalent elements[.](#10.sentence-2)
[11](#11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L19378)
*Complexity*: N + MlogM, where N is size() before the operation and M is ranges::distance(rg)[.](#11.sentence-1)
[12](#12)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L19383)
*Remarks*: Since this operation performs an in-place merge, it may allocate memory[.](#12.sentence-1)
[🔗](#lib:swap,flat_set)
`constexpr void swap(flat_set& y) noexcept;
`
[13](#13)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L19394)
*Effects*: Equivalent to:ranges::swap(*compare*, y.*compare*);
ranges::swap(*c*, y.*c*);
[🔗](#lib:extract,flat_set)
`constexpr container_type extract() &&;
`
[14](#14)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L19409)
*Postconditions*: *this is emptied, even if the function exits via an exception[.](#14.sentence-1)
[15](#15)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L19413)
*Returns*: std::move(*c*)[.](#15.sentence-1)
[🔗](#lib:replace,flat_set)
`constexpr void replace(container_type&& cont);
`
[16](#16)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L19424)
*Preconditions*: The elements of cont are sorted with respect to *compare*, andcont contains no equal elements[.](#16.sentence-1)
[17](#17)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L19429)
*Effects*: Equivalent to: *c* = std::move(cont);

View File

@@ -0,0 +1,137 @@
[flat.set.overview]
# 23 Containers library [[containers]](./#containers)
## 23.6 Container adaptors [[container.adaptors]](container.adaptors#flat.set.overview)
### 23.6.11 Class template flat_set [[flat.set]](flat.set#overview)
#### 23.6.11.1 Overview [flat.set.overview]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L18805)
A flat_set is a container adaptor
that provides an associative container interface
that supports unique keys
(i.e., contains at most one of each key value) and
provides for fast retrieval of the keys themselves[.](#1.sentence-1)
flat_set supports iterators that model
the [random_access_iterator](iterator.concept.random.access#concept:random_access_iterator "24.3.4.13Concept random_­access_­iterator[iterator.concept.random.access]") concept ([[iterator.concept.random.access]](iterator.concept.random.access "24.3.4.13Concept random_­access_­iterator"))[.](#1.sentence-2)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L18815)
A flat_set meets all of the requirements
for a container ([[container.reqmts]](container.reqmts "23.2.2.2Container requirements")) and
for a reversible container ([[container.rev.reqmts]](container.rev.reqmts "23.2.2.3Reversible container requirements")),
plus the optional container requirements ([[container.opt.reqmts]](container.opt.reqmts "23.2.2.4Optional container requirements"))[.](#2.sentence-1)
flat_set meets the requirements of
an associative container ([[associative.reqmts]](associative.reqmts "23.2.7Associative containers")), except that:
- [(2.1)](#2.1)
it does not meet the requirements
related to node handles ([[container.node.overview]](container.node.overview "23.2.5.1Overview")),
- [(2.2)](#2.2)
it does not meet the requirements related to iterator invalidation, and
- [(2.3)](#2.3)
the time complexity of the operations
that insert or erase a single element from the set
is linear,
including the ones that take an insertion position iterator[.](#2.sentence-2)
[*Note [1](#note-1)*:
A flat_set does not meet
the additional requirements of an allocator-aware container,
as described in [[container.alloc.reqmts]](container.alloc.reqmts "23.2.2.5Allocator-aware containers")[.](#2.sentence-3)
— *end note*]
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L18840)
A flat_set also provides most operations
described in [[associative.reqmts]](associative.reqmts "23.2.7Associative containers") for unique keys[.](#3.sentence-1)
This means that a flat_set supports
the a_uniq operations in [[associative.reqmts]](associative.reqmts "23.2.7Associative containers") but not the a_eq operations[.](#3.sentence-2)
For a flat_set<Key>,
both the key_type and value_type are Key[.](#3.sentence-3)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L18849)
Descriptions are provided here only for operations on flat_set that are not described in one of those sets of requirements or
for operations where there is additional semantic information[.](#4.sentence-1)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L18854)
A flat_set maintains the invariant that the keys are sorted with
respect to the comparison object[.](#5.sentence-1)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L18858)
If any member function in [[flat.set.defn]](flat.set.defn "23.6.11.2Definition") exits via an exception,
the invariant is restored[.](#6.sentence-1)
[*Note [2](#note-2)*:
This can result in the flat_set's being emptied[.](#6.sentence-2)
— *end note*]
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L18865)
Any sequence container ([[sequence.reqmts]](sequence.reqmts "23.2.4Sequence containers"))
supporting *Cpp17RandomAccessIterator* can be used to instantiate flat_set[.](#7.sentence-1)
In particular, vector ([[vector]](vector "23.3.13Class template vector")) and deque ([[deque]](deque "23.3.5Class template deque"))
can be used[.](#7.sentence-2)
[*Note [3](#note-3)*:
vector<bool> is not a sequence container[.](#7.sentence-3)
— *end note*]
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L18875)
The program is ill-formed if Key is not the same type
as KeyContainer::value_type[.](#8.sentence-1)
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L18879)
The effect of calling a constructor or member function
that takes a sorted_unique_t argument
with a range that is not sorted with respect to key_comp(), or
that contains equal elements, is undefined[.](#9.sentence-1)
[10](#10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L18885)
The types iterator and const_iterator meet
the constexpr iterator requirements ([[iterator.requirements.general]](iterator.requirements.general "24.3.1General"))[.](#10.sentence-1)

11
cppdraft/flat/set/syn.md Normal file
View File

@@ -0,0 +1,11 @@
[flat.set.syn]
# 23 Containers library [[containers]](./#containers)
## 23.6 Container adaptors [[container.adaptors]](container.adaptors#flat.set.syn)
### 23.6.10 Header <flat_set> synopsis [flat.set.syn]
#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 {// [[flat.set]](flat.set "23.6.11Class template flat_­set"), class template flat_settemplate<class Key, class Compare = less<Key>, class KeyContainer = vector<Key>>class flat_set; struct sorted_unique_t { explicit sorted_unique_t() = default; }; inline constexpr sorted_unique_t sorted_unique{}; template<class Key, class Compare, class KeyContainer, class Allocator>struct uses_allocator<flat_set<Key, Compare, KeyContainer>, Allocator>; // [[flat.set.erasure]](flat.set.erasure "23.6.11.6Erasure"), erasure for flat_settemplate<class Key, class Compare, class KeyContainer, class Predicate>constexpr typename flat_set<Key, Compare, KeyContainer>::size_type
erase_if(flat_set<Key, Compare, KeyContainer>& c, Predicate pred); // [[flat.multiset]](flat.multiset "23.6.12Class template flat_­multiset"), class template flat_multisettemplate<class Key, class Compare = less<Key>, class KeyContainer = vector<Key>>class flat_multiset; struct sorted_equivalent_t { explicit sorted_equivalent_t() = default; }; inline constexpr sorted_equivalent_t sorted_equivalent{}; template<class Key, class Compare, class KeyContainer, class Allocator>struct uses_allocator<flat_multiset<Key, Compare, KeyContainer>, Allocator>; // [[flat.multiset.erasure]](flat.multiset.erasure "23.6.12.6Erasure"), erasure for flat_multisettemplate<class Key, class Compare, class KeyContainer, class Predicate>constexpr typename flat_multiset<Key, Compare, KeyContainer>::size_type
erase_if(flat_multiset<Key, Compare, KeyContainer>& c, Predicate pred);}