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

67
cppdraft/tuple/swap.md Normal file
View File

@@ -0,0 +1,67 @@
[tuple.swap]
# 22 General utilities library [[utilities]](./#utilities)
## 22.4 Tuples [[tuple]](tuple#swap)
### 22.4.4 Class template tuple [[tuple.tuple]](tuple.tuple#tuple.swap)
#### 22.4.4.4 swap [tuple.swap]
[🔗](#lib:swap,tuple)
`constexpr void swap(tuple& rhs) noexcept(see below);
constexpr void swap(const tuple& rhs) const noexcept(see below);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2532)
Let i be in the range [0, sizeof...(Types)) in order[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2535)
*Mandates*:
- [(2.1)](#2.1)
For the first overload,(is_swappable_v<Types> && ...) is true[.](#2.1.sentence-1)
- [(2.2)](#2.2)
For the second overload,(is_swappable_v<const Types> && ...) is true[.](#2.2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2546)
*Preconditions*: For all i, get<i>(*this) is swappable with ([[swappable.requirements]](swappable.requirements "16.4.4.3Swappable requirements")) get<i>(rhs)[.](#3.sentence-1)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2550)
*Effects*: For each i, calls swap for get<i>(*this) and get<i>(rhs)[.](#4.sentence-1)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2554)
*Throws*: Nothing unless one of the element-wise swap calls throws an exception[.](#5.sentence-1)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2558)
*Remarks*: The exception specification is equivalent to
- [(6.1)](#6.1)
(is_nothrow_swappable_v<Types> && ...) for the first overload and
- [(6.2)](#6.2)
(is_nothrow_swappable_v<const Types> && ...) for the second overload[.](#6.sentence-1)