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