Files
cppdraft_translate/cppdraft/tuple/swap.md
2025-10-25 03:02:53 +03:00

68 lines
1.9 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[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)