From Jason Turner

[variant.swap]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmptmjabkon/{from.md → to.md} +35 -0
tmp/tmptmjabkon/{from.md → to.md} RENAMED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #### Swap <a id="variant.swap">[[variant.swap]]</a>
2
+
3
+ ``` cpp
4
+ void swap(variant& rhs) noexcept(see below);
5
+ ```
6
+
7
+ *Requires:* Lvalues of type `Tᵢ` shall be
8
+ swappable ([[swappable.requirements]]) and
9
+ `is_move_constructible_v<``Tᵢ``>` shall be `true` for all i.
10
+
11
+ *Effects:*
12
+
13
+ - if `valueless_by_exception() && rhs.valueless_by_exception()` no
14
+ effect. Otherwise,
15
+ - if `index() == rhs.index()`, calls
16
+ `swap(get<`i`>(*this), get<`i`>(rhs))` where i is `index()`.
17
+ Otherwise,
18
+ - exchanges values of `rhs` and `*this`.
19
+
20
+ *Throws:* If `index() == rhs.index()`, any exception thrown by
21
+ `swap(get<`i`>(*this), get<`i`>(rhs))` with i being `index()`.
22
+ Otherwise, any exception thrown by the move constructor of `Tᵢ` or `Tⱼ`
23
+ with i being `index()` and j being `rhs.index()`.
24
+
25
+ *Remarks:* If an exception is thrown during the call to function
26
+ `swap(get<`i`>(*this), get<`i`>(rhs))`, the states of the contained
27
+ values of `*this` and of `rhs` are determined by the exception safety
28
+ guarantee of `swap` for lvalues of `Tᵢ` with i being `index()`. If an
29
+ exception is thrown during the exchange of the values of `*this` and
30
+ `rhs`, the states of the values of `*this` and of `rhs` are determined
31
+ by the exception safety guarantee of `variant`’s move constructor. The
32
+ expression inside `noexcept` is equivalent to the logical AND of
33
+ `is_nothrow_move_constructible_v<``Tᵢ``> && is_nothrow_swappable_v<``Tᵢ``>`
34
+ for all i.
35
+