tmp/tmp121g8eor/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#### Swap <a id="optional.swap">[[optional.swap]]</a>
|
| 2 |
+
|
| 3 |
+
``` cpp
|
| 4 |
+
void swap(optional& rhs) noexcept(see below);
|
| 5 |
+
```
|
| 6 |
+
|
| 7 |
+
*Requires:* Lvalues of type `T` shall be swappable and
|
| 8 |
+
`is_move_constructible_v<T>` is `true`.
|
| 9 |
+
|
| 10 |
+
*Effects:* See Table [[tab:optional.swap]].
|
| 11 |
+
|
| 12 |
+
**Table: `optional::swap(optional&)` effects** <a id="tab:optional.swap">[tab:optional.swap]</a>
|
| 13 |
+
|
| 14 |
+
| | `*this` contains a value | `*this` does not contain a value |
|
| 15 |
+
| ------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
| 16 |
+
| `rhs` contains a value | calls `swap(*(*this), *rhs)` | initializes the contained value of `*this` as if direct-non-list-initializing an object of type `T` with the expression `std::move(*rhs)`, followed by `rhs.val->T::~T()`; postcondition is that `*this` contains a value and `rhs` does not contain a value |
|
| 17 |
+
| `rhs` does not contain a value | initializes the contained value of `rhs` as if direct-non-list-initializing an object of type `T` with the expression `std::move(*(*this))`, followed by `val->T::~T()`; postcondition is that `*this` does not contain a value and `rhs` contains a value | no effect |
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
*Throws:* Any exceptions thrown by the operations in the relevant part
|
| 21 |
+
of Table [[tab:optional.swap]].
|
| 22 |
+
|
| 23 |
+
*Remarks:* The expression inside `noexcept` is equivalent to:
|
| 24 |
+
|
| 25 |
+
``` cpp
|
| 26 |
+
is_nothrow_move_constructible_v<T> && is_nothrow_swappable_v<T>
|
| 27 |
+
```
|
| 28 |
+
|
| 29 |
+
If any exception is thrown, the results of the expressions `bool(*this)`
|
| 30 |
+
and `bool(rhs)` remain unchanged. If an exception is thrown during the
|
| 31 |
+
call to function `swap`, the state of `*val` and `*rhs.val` is
|
| 32 |
+
determined by the exception safety guarantee of `swap` for lvalues of
|
| 33 |
+
`T`. If an exception is thrown during the call to `T`’s move
|
| 34 |
+
constructor, the state of `*val` and `*rhs.val` is determined by the
|
| 35 |
+
exception safety guarantee of `T`’s move constructor.
|
| 36 |
+
|