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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#### Assignment <a id="optional.assign">[[optional.assign]]</a>
|
| 2 |
+
|
| 3 |
+
``` cpp
|
| 4 |
+
optional<T>& operator=(nullopt_t) noexcept;
|
| 5 |
+
```
|
| 6 |
+
|
| 7 |
+
*Effects:* If `*this` contains a value, calls `val->T::T̃()` to destroy
|
| 8 |
+
the contained value; otherwise no effect.
|
| 9 |
+
|
| 10 |
+
*Returns:* `*this`.
|
| 11 |
+
|
| 12 |
+
*Postconditions:* `*this` does not contain a value.
|
| 13 |
+
|
| 14 |
+
``` cpp
|
| 15 |
+
optional<T>& operator=(const optional& rhs);
|
| 16 |
+
```
|
| 17 |
+
|
| 18 |
+
*Effects:* See Table [[tab:optional.assign.copy]].
|
| 19 |
+
|
| 20 |
+
**Table: `optional::operator=(const optional&)` effects** <a id="tab:optional.assign.copy">[tab:optional.assign.copy]</a>
|
| 21 |
+
|
| 22 |
+
| | `*this` contains a value | `*this` does not contain a value |
|
| 23 |
+
| ------------------------------ | ------------------------------------------------------ | ---------------------------------------------------------------------------------------------------- |
|
| 24 |
+
| `rhs` contains a value | assigns `*rhs` to the contained value | initializes the contained value as if direct-non-list-initializing an object of type `T` with `*rhs` |
|
| 25 |
+
| `rhs` does not contain a value | destroys the contained value by calling `val->T::~T()` | no effect |
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
*Returns:* `*this`.
|
| 29 |
+
|
| 30 |
+
*Postconditions:* `bool(rhs) == bool(*this)`.
|
| 31 |
+
|
| 32 |
+
*Remarks:* If any exception is thrown, the result of the expression
|
| 33 |
+
`bool(*this)` remains unchanged. If an exception is thrown during the
|
| 34 |
+
call to `T`’s copy constructor, no effect. If an exception is thrown
|
| 35 |
+
during the call to `T`’s copy assignment, the state of its contained
|
| 36 |
+
value is as defined by the exception safety guarantee of `T`’s copy
|
| 37 |
+
assignment. This operator shall be defined as deleted unless
|
| 38 |
+
`is_copy_constructible_v<T>` is `true` and `is_copy_assignable_v<T>` is
|
| 39 |
+
`true`.
|
| 40 |
+
|
| 41 |
+
``` cpp
|
| 42 |
+
optional<T>& operator=(optional&& rhs) noexcept(see below);
|
| 43 |
+
```
|
| 44 |
+
|
| 45 |
+
*Effects:* See Table [[tab:optional.assign.move]]. The result of the
|
| 46 |
+
expression `bool(rhs)` remains unchanged.
|
| 47 |
+
|
| 48 |
+
**Table: `optional::operator=(optional&&)` effects** <a id="tab:optional.assign.move">[tab:optional.assign.move]</a>
|
| 49 |
+
|
| 50 |
+
| | `*this` contains a value | `*this` does not contain a value |
|
| 51 |
+
| ------------------------------ | ------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------- |
|
| 52 |
+
| `rhs` contains a value | assigns `std::move(*rhs)` to the contained value | initializes the contained value as if direct-non-list-initializing an object of type `T` with `std::move(*rhs)` |
|
| 53 |
+
| `rhs` does not contain a value | destroys the contained value by calling `val->T::~T()` | no effect |
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
*Returns:* `*this`.
|
| 57 |
+
|
| 58 |
+
*Postconditions:* `bool(rhs) == bool(*this)`.
|
| 59 |
+
|
| 60 |
+
*Remarks:* The expression inside `noexcept` is equivalent to:
|
| 61 |
+
|
| 62 |
+
``` cpp
|
| 63 |
+
is_nothrow_move_assignable_v<T> && is_nothrow_move_constructible_v<T>
|
| 64 |
+
```
|
| 65 |
+
|
| 66 |
+
If any exception is thrown, the result of the expression `bool(*this)`
|
| 67 |
+
remains unchanged. If an exception is thrown during the call to `T`’s
|
| 68 |
+
move constructor, the state of `*rhs.val` is determined by the exception
|
| 69 |
+
safety guarantee of `T`’s move constructor. If an exception is thrown
|
| 70 |
+
during the call to `T`’s move assignment, the state of `*val` and
|
| 71 |
+
`*rhs.val` is determined by the exception safety guarantee of `T`’s move
|
| 72 |
+
assignment. This operator shall not participate in overload resolution
|
| 73 |
+
unless `is_move_constructible_v<T>` is `true` and
|
| 74 |
+
`is_move_assignable_v<T>` is `true`.
|
| 75 |
+
|
| 76 |
+
``` cpp
|
| 77 |
+
template <class U = T> optional<T>& operator=(U&& v);
|
| 78 |
+
```
|
| 79 |
+
|
| 80 |
+
*Effects:* If `*this` contains a value, assigns `std::forward<U>(v)` to
|
| 81 |
+
the contained value; otherwise initializes the contained value as if
|
| 82 |
+
direct-non-list-initializing object of type `T` with
|
| 83 |
+
`std::forward<U>(v)`.
|
| 84 |
+
|
| 85 |
+
*Returns:* `*this`.
|
| 86 |
+
|
| 87 |
+
*Postconditions:* `*this` contains a value.
|
| 88 |
+
|
| 89 |
+
*Remarks:* If any exception is thrown, the result of the expression
|
| 90 |
+
`bool(*this)` remains unchanged. If an exception is thrown during the
|
| 91 |
+
call to `T`’s constructor, the state of `v` is determined by the
|
| 92 |
+
exception safety guarantee of `T`’s constructor. If an exception is
|
| 93 |
+
thrown during the call to `T`’s assignment, the state of `*val` and `v`
|
| 94 |
+
is determined by the exception safety guarantee of `T`’s assignment.
|
| 95 |
+
This function shall not participate in overload resolution unless
|
| 96 |
+
`is_same_v<optional<T>, decay_t<U>>` is `false`,
|
| 97 |
+
`conjunction_v<is_scalar<T>, is_same<T, decay_t<U>>>` is `false`,
|
| 98 |
+
`is_constructible_v<T, U>` is `true`, and `is_assignable_v<T&, U>` is
|
| 99 |
+
`true`.
|
| 100 |
+
|
| 101 |
+
``` cpp
|
| 102 |
+
template <class U> optional<T>& operator=(const optional<U>& rhs);
|
| 103 |
+
```
|
| 104 |
+
|
| 105 |
+
*Effects:* See Table [[tab:optional.assign.copy.templ]].
|
| 106 |
+
|
| 107 |
+
**Table: `optional::operator=(const optional<U>&)` effects** <a id="tab:optional.assign.copy.templ">[tab:optional.assign.copy.templ]</a>
|
| 108 |
+
|
| 109 |
+
| | `*this` contains a value | `*this` does not contain a value |
|
| 110 |
+
| ------------------------------ | ------------------------------------------------------ | ---------------------------------------------------------------------------------------------------- |
|
| 111 |
+
| `rhs` contains a value | assigns `*rhs` to the contained value | initializes the contained value as if direct-non-list-initializing an object of type `T` with `*rhs` |
|
| 112 |
+
| `rhs` does not contain a value | destroys the contained value by calling `val->T::~T()` | no effect |
|
| 113 |
+
|
| 114 |
+
|
| 115 |
+
*Returns:* `*this`.
|
| 116 |
+
|
| 117 |
+
*Postconditions:* `bool(rhs) == bool(*this)`.
|
| 118 |
+
|
| 119 |
+
*Remarks:* If any exception is thrown, the result of the expression
|
| 120 |
+
`bool(*this)` remains unchanged. If an exception is thrown during the
|
| 121 |
+
call to `T`’s constructor, the state of `*rhs.val` is determined by the
|
| 122 |
+
exception safety guarantee of `T`’s constructor. If an exception is
|
| 123 |
+
thrown during the call to `T`’s assignment, the state of `*val` and
|
| 124 |
+
`*rhs.val` is determined by the exception safety guarantee of `T`’s
|
| 125 |
+
assignment. This function shall not participate in overload resolution
|
| 126 |
+
unless
|
| 127 |
+
|
| 128 |
+
- `is_constructible_v<T, const U&>` is `true`,
|
| 129 |
+
- `is_assignable_v<T&, const U&>` is `true`,
|
| 130 |
+
- `is_constructible_v<T, optional<U>&>` is `false`,
|
| 131 |
+
- `is_constructible_v<T, optional<U>&&>` is `false`,
|
| 132 |
+
- `is_constructible_v<T, const optional<U>&>` is `false`,
|
| 133 |
+
- `is_constructible_v<T, const optional<U>&&>` is `false`,
|
| 134 |
+
- `is_convertible_v<optional<U>&, T>` is `false`,
|
| 135 |
+
- `is_convertible_v<optional<U>&&, T>` is `false`,
|
| 136 |
+
- `is_convertible_v<const optional<U>&, T>` is `false`,
|
| 137 |
+
- `is_convertible_v<const optional<U>&&, T>` is `false`,
|
| 138 |
+
- `is_assignable_v<T&, optional<U>&>` is `false`,
|
| 139 |
+
- `is_assignable_v<T&, optional<U>&&>` is `false`,
|
| 140 |
+
- `is_assignable_v<T&, const optional<U>&>` is `false`, and
|
| 141 |
+
- `is_assignable_v<T&, const optional<U>&&>` is `false`.
|
| 142 |
+
|
| 143 |
+
``` cpp
|
| 144 |
+
template <class U> optional<T>& operator=(optional<U>&& rhs);
|
| 145 |
+
```
|
| 146 |
+
|
| 147 |
+
*Effects:* See Table [[tab:optional.assign.move.templ]]. The result of
|
| 148 |
+
the expression `bool(rhs)` remains unchanged.
|
| 149 |
+
|
| 150 |
+
**Table: `optional::operator=(optional<U>&&)` effects** <a id="tab:optional.assign.move.templ">[tab:optional.assign.move.templ]</a>
|
| 151 |
+
|
| 152 |
+
| | `*this` contains a value | `*this` does not contain a value |
|
| 153 |
+
| ------------------------------ | ------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------- |
|
| 154 |
+
| `rhs` contains a value | assigns `std::move(*rhs)` to the contained value | initializes the contained value as if direct-non-list-initializing an object of type `T` with `std::move(*rhs)` |
|
| 155 |
+
| `rhs` does not contain a value | destroys the contained value by calling `val->T::~T()` | no effect |
|
| 156 |
+
|
| 157 |
+
|
| 158 |
+
*Returns:* `*this`.
|
| 159 |
+
|
| 160 |
+
*Postconditions:* `bool(rhs) == bool(*this)`.
|
| 161 |
+
|
| 162 |
+
*Remarks:* If any exception is thrown, the result of the expression
|
| 163 |
+
`bool(*this)` remains unchanged. If an exception is thrown during the
|
| 164 |
+
call to `T`’s constructor, the state of `*rhs.val` is determined by the
|
| 165 |
+
exception safety guarantee of `T`’s constructor. If an exception is
|
| 166 |
+
thrown during the call to `T`’s assignment, the state of `*val` and
|
| 167 |
+
`*rhs.val` is determined by the exception safety guarantee of `T`’s
|
| 168 |
+
assignment. This function shall not participate in overload resolution
|
| 169 |
+
unless
|
| 170 |
+
|
| 171 |
+
- `is_constructible_v<T, U>` is `true`,
|
| 172 |
+
- `is_assignable_v<T&, U>` is `true`,
|
| 173 |
+
- `is_constructible_v<T, optional<U>&>` is `false`,
|
| 174 |
+
- `is_constructible_v<T, optional<U>&&>` is `false`,
|
| 175 |
+
- `is_constructible_v<T, const optional<U>&>` is `false`,
|
| 176 |
+
- `is_constructible_v<T, const optional<U>&&>` is `false`,
|
| 177 |
+
- `is_convertible_v<optional<U>&, T>` is `false`,
|
| 178 |
+
- `is_convertible_v<optional<U>&&, T>` is `false`,
|
| 179 |
+
- `is_convertible_v<const optional<U>&, T>` is `false`,
|
| 180 |
+
- `is_convertible_v<const optional<U>&&, T>` is `false`,
|
| 181 |
+
- `is_assignable_v<T&, optional<U>&>` is `false`,
|
| 182 |
+
- `is_assignable_v<T&, optional<U>&&>` is `false`,
|
| 183 |
+
- `is_assignable_v<T&, const optional<U>&>` is `false`, and
|
| 184 |
+
- `is_assignable_v<T&, const optional<U>&&>` is `false`.
|
| 185 |
+
|
| 186 |
+
``` cpp
|
| 187 |
+
template <class... Args> T& emplace(Args&&... args);
|
| 188 |
+
```
|
| 189 |
+
|
| 190 |
+
*Requires:* `is_constructible_v<T, Args&&...>` is `true`.
|
| 191 |
+
|
| 192 |
+
*Effects:* Calls `*this = nullopt`. Then initializes the contained value
|
| 193 |
+
as if direct-non-list-initializing an object of type `T` with the
|
| 194 |
+
arguments `std::forward<Args>(args)...`.
|
| 195 |
+
|
| 196 |
+
*Postconditions:* `*this` contains a value.
|
| 197 |
+
|
| 198 |
+
*Returns:* A reference to the new contained value.
|
| 199 |
+
|
| 200 |
+
*Throws:* Any exception thrown by the selected constructor of `T`.
|
| 201 |
+
|
| 202 |
+
*Remarks:* If an exception is thrown during the call to `T`’s
|
| 203 |
+
constructor, `*this` does not contain a value, and the previous `*val`
|
| 204 |
+
(if any) has been destroyed.
|
| 205 |
+
|
| 206 |
+
``` cpp
|
| 207 |
+
template <class U, class... Args> T& emplace(initializer_list<U> il, Args&&... args);
|
| 208 |
+
```
|
| 209 |
+
|
| 210 |
+
*Effects:* Calls `*this = nullopt`. Then initializes the contained value
|
| 211 |
+
as if direct-non-list-initializing an object of type `T` with the
|
| 212 |
+
arguments `il, std::forward<Args>(args)...`.
|
| 213 |
+
|
| 214 |
+
*Postconditions:* `*this` contains a value.
|
| 215 |
+
|
| 216 |
+
*Returns:* A reference to the new contained value.
|
| 217 |
+
|
| 218 |
+
*Throws:* Any exception thrown by the selected constructor of `T`.
|
| 219 |
+
|
| 220 |
+
*Remarks:* If an exception is thrown during the call to `T`’s
|
| 221 |
+
constructor, `*this` does not contain a value, and the previous `*val`
|
| 222 |
+
(if any) has been destroyed. This function shall not participate in
|
| 223 |
+
overload resolution unless
|
| 224 |
+
`is_constructible_v<T, initializer_list<U>&, Args&&...>` is `true`.
|
| 225 |
+
|