From Jason Turner

[expected.void.swap]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpnzfdmjo_/{from.md → to.md} +38 -0
tmp/tmpnzfdmjo_/{from.md → to.md} RENAMED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #### Swap <a id="expected.void.swap">[[expected.void.swap]]</a>
2
+
3
+ ``` cpp
4
+ constexpr void swap(expected& rhs) noexcept(see below);
5
+ ```
6
+
7
+ *Constraints:* `is_swappable_v<E>` is `true` and
8
+ `is_move_constructible_v<E>` is `true`.
9
+
10
+ *Effects:* See [[expected.void.swap]].
11
+
12
+ **Table: `swap(expected&)` effects** <a id="expected.void.swap">[expected.void.swap]</a>
13
+
14
+ | \topline | `this->has_value()` | `!this->has_value()` |
15
+ | -------- | ------------------- | -------------------- |
16
+
17
+
18
+ For the case where `rhs.value()` is `false` and `this->has_value()` is
19
+ `true`, equivalent to:
20
+
21
+ ``` cpp
22
+ construct_at(addressof(unex), std::move(rhs.unex));
23
+ destroy_at(addressof(rhs.unex));
24
+ has_val = false;
25
+ rhs.has_val = true;
26
+ ```
27
+
28
+ *Throws:* Any exception thrown by the expressions in the *Effects*.
29
+
30
+ *Remarks:* The exception specification is equivalent to
31
+ `is_nothrow_move_constructible_v<E> && is_nothrow_swappable_v<E>`.
32
+
33
+ ``` cpp
34
+ friend constexpr void swap(expected& x, expected& y) noexcept(noexcept(x.swap(y)));
35
+ ```
36
+
37
+ *Effects:* Equivalent to `x.swap(y)`.
38
+