From Jason Turner

[optional.swap]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpkir4l9ny/{from.md → to.md} +14 -13
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:* Lvalues of type `T` are swappable.
 
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)` | 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 |
18
- | `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 |
19
 
20
 
21
  *Throws:* Any exceptions thrown by the operations in the relevant part
22
  of [[optional.swap]].
23
 
24
- *Remarks:* The expression inside `noexcept` is equivalent to:
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 `bool(*this)`
31
- and `bool(rhs)` remain unchanged. If an exception is thrown during the
32
- call to function `swap`, the state of `*val` and `*rhs.val` is
33
- determined by the exception safety guarantee of `swap` for lvalues of
34
- `T`. If an exception is thrown during the call to `T`’s move
35
- constructor, the state of `*val` and `*rhs.val` is determined by the
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