tmp/tmprch8zdtq/{from.md → to.md}
RENAMED
|
@@ -52,12 +52,12 @@ public:
|
|
| 52 |
|
| 53 |
// [expected.void.obs], observers
|
| 54 |
constexpr explicit operator bool() const noexcept;
|
| 55 |
constexpr bool has_value() const noexcept;
|
| 56 |
constexpr void operator*() const noexcept;
|
| 57 |
-
constexpr void value() const &;
|
| 58 |
-
constexpr void value() &&;
|
| 59 |
constexpr const E& error() const & noexcept;
|
| 60 |
constexpr E& error() & noexcept;
|
| 61 |
constexpr const E&& error() const && noexcept;
|
| 62 |
constexpr E&& error() && noexcept;
|
| 63 |
template<class G = E> constexpr E error_or(G&&) const &;
|
|
@@ -94,15 +94,13 @@ private:
|
|
| 94 |
};
|
| 95 |
};
|
| 96 |
```
|
| 97 |
|
| 98 |
Any object of type `expected<T, E>` either represents a value of type
|
| 99 |
-
`T`, or contains a value of type `E` within
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
indicates whether the `expected<T, E>` object represents a value of type
|
| 103 |
-
`T`.
|
| 104 |
|
| 105 |
A program that instantiates the definition of the template
|
| 106 |
`expected<T, E>` with a type for the `E` parameter that is not a valid
|
| 107 |
template argument for `unexpected` is ill-formed.
|
| 108 |
|
|
@@ -267,10 +265,13 @@ constexpr expected& operator=(const expected& rhs);
|
|
| 267 |
|
| 268 |
``` cpp
|
| 269 |
constexpr expected& operator=(expected&& rhs) noexcept(see below);
|
| 270 |
```
|
| 271 |
|
|
|
|
|
|
|
|
|
|
| 272 |
*Effects:*
|
| 273 |
|
| 274 |
- If `this->has_value() && rhs.has_value()` is `true`, no effects.
|
| 275 |
- Otherwise, if `this->has_value()` is `true`, equivalent to:
|
| 276 |
``` cpp
|
|
@@ -284,13 +285,10 @@ constexpr expected& operator=(expected&& rhs) noexcept(see below);
|
|
| 284 |
*Returns:* `*this`.
|
| 285 |
|
| 286 |
*Remarks:* The exception specification is equivalent to
|
| 287 |
`is_nothrow_move_constructible_v<E> && is_nothrow_move_assignable_v<E>`.
|
| 288 |
|
| 289 |
-
This operator is defined as deleted unless `is_move_constructible_v<E>`
|
| 290 |
-
is `true` and `is_move_assignable_v<E>` is `true`.
|
| 291 |
-
|
| 292 |
``` cpp
|
| 293 |
template<class G>
|
| 294 |
constexpr expected& operator=(const unexpected<G>& e);
|
| 295 |
template<class G>
|
| 296 |
constexpr expected& operator=(unexpected<G>&& e);
|
|
@@ -335,12 +333,12 @@ constexpr void swap(expected& rhs) noexcept(see below);
|
|
| 335 |
|
| 336 |
| \topline | `this->has_value()` | `!this->has_value()` |
|
| 337 |
| -------- | ------------------- | -------------------- |
|
| 338 |
|
| 339 |
|
| 340 |
-
For the case where `rhs.
|
| 341 |
-
`true`, equivalent to:
|
| 342 |
|
| 343 |
``` cpp
|
| 344 |
construct_at(addressof(unex), std::move(rhs.unex));
|
| 345 |
destroy_at(addressof(rhs.unex));
|
| 346 |
has_val = false;
|
|
@@ -369,40 +367,45 @@ constexpr bool has_value() const noexcept;
|
|
| 369 |
|
| 370 |
``` cpp
|
| 371 |
constexpr void operator*() const noexcept;
|
| 372 |
```
|
| 373 |
|
| 374 |
-
|
| 375 |
|
| 376 |
``` cpp
|
| 377 |
constexpr void value() const &;
|
| 378 |
```
|
| 379 |
|
|
|
|
|
|
|
| 380 |
*Throws:* `bad_expected_access(error())` if `has_value()` is `false`.
|
| 381 |
|
| 382 |
``` cpp
|
| 383 |
constexpr void value() &&;
|
| 384 |
```
|
| 385 |
|
|
|
|
|
|
|
|
|
|
| 386 |
*Throws:* `bad_expected_access(std::move(error()))` if `has_value()` is
|
| 387 |
`false`.
|
| 388 |
|
| 389 |
``` cpp
|
| 390 |
constexpr const E& error() const & noexcept;
|
| 391 |
constexpr E& error() & noexcept;
|
| 392 |
```
|
| 393 |
|
| 394 |
-
|
| 395 |
|
| 396 |
*Returns:* *unex*.
|
| 397 |
|
| 398 |
``` cpp
|
| 399 |
constexpr E&& error() && noexcept;
|
| 400 |
constexpr const E&& error() const && noexcept;
|
| 401 |
```
|
| 402 |
|
| 403 |
-
|
| 404 |
|
| 405 |
*Returns:* `std::move(`*`unex`*`)`.
|
| 406 |
|
| 407 |
``` cpp
|
| 408 |
template<class G = E> constexpr E error_or(G&& e) const &;
|
|
@@ -434,11 +437,11 @@ template<class F> constexpr auto and_then(F&& f) const &;
|
|
| 434 |
Let `U` be `remove_cvref_t<invoke_result_t<F>>`.
|
| 435 |
|
| 436 |
*Constraints:* `is_constructible_v<E, decltype(error())>>` is `true`.
|
| 437 |
|
| 438 |
*Mandates:* `U` is a specialization of `expected` and
|
| 439 |
-
`is_same_v<U::error_type, E>` is `true`.
|
| 440 |
|
| 441 |
*Effects:* Equivalent to:
|
| 442 |
|
| 443 |
``` cpp
|
| 444 |
if (has_value())
|
|
@@ -456,11 +459,11 @@ Let `U` be `remove_cvref_t<invoke_result_t<F>>`.
|
|
| 456 |
|
| 457 |
*Constraints:* `is_constructible_v<E, decltype(std::move(error()))>` is
|
| 458 |
`true`.
|
| 459 |
|
| 460 |
*Mandates:* `U` is a specialization of `expected` and
|
| 461 |
-
`is_same_v<U::error_type, E>` is `true`.
|
| 462 |
|
| 463 |
*Effects:* Equivalent to:
|
| 464 |
|
| 465 |
``` cpp
|
| 466 |
if (has_value())
|
|
@@ -475,11 +478,11 @@ template<class F> constexpr auto or_else(F&& f) const &;
|
|
| 475 |
```
|
| 476 |
|
| 477 |
Let `G` be `remove_cvref_t<invoke_result_t<F, decltype(error())>>`.
|
| 478 |
|
| 479 |
*Mandates:* `G` is a specialization of `expected` and
|
| 480 |
-
`is_same_v<G::value_type, T>` is `true`.
|
| 481 |
|
| 482 |
*Effects:* Equivalent to:
|
| 483 |
|
| 484 |
``` cpp
|
| 485 |
if (has_value())
|
|
@@ -495,11 +498,11 @@ template<class F> constexpr auto or_else(F&& f) const &&;
|
|
| 495 |
|
| 496 |
Let `G` be
|
| 497 |
`remove_cvref_t<invoke_result_t<F, decltype(std::move(error()))>>`.
|
| 498 |
|
| 499 |
*Mandates:* `G` is a specialization of `expected` and
|
| 500 |
-
`is_same_v<G::value_type, T>` is `true`.
|
| 501 |
|
| 502 |
*Effects:* Equivalent to:
|
| 503 |
|
| 504 |
``` cpp
|
| 505 |
if (has_value())
|
|
@@ -613,22 +616,22 @@ member is direct-non-list-initialized with
|
|
| 613 |
``` cpp
|
| 614 |
template<class T2, class E2> requires is_void_v<T2>
|
| 615 |
friend constexpr bool operator==(const expected& x, const expected<T2, E2>& y);
|
| 616 |
```
|
| 617 |
|
| 618 |
-
*
|
| 619 |
-
its result is convertible to `bool`.
|
| 620 |
|
| 621 |
*Returns:* If `x.has_value()` does not equal `y.has_value()`, `false`;
|
| 622 |
otherwise `x.has_value() || static_cast<bool>(x.error() == y.error())`.
|
| 623 |
|
| 624 |
``` cpp
|
| 625 |
template<class E2>
|
| 626 |
friend constexpr bool operator==(const expected& x, const unexpected<E2>& e);
|
| 627 |
```
|
| 628 |
|
| 629 |
-
*
|
| 630 |
-
its result is convertible to `bool`.
|
| 631 |
|
| 632 |
*Returns:*
|
| 633 |
`!x.has_value() && static_cast<bool>(x.error() == e.error())`.
|
| 634 |
|
|
|
|
| 52 |
|
| 53 |
// [expected.void.obs], observers
|
| 54 |
constexpr explicit operator bool() const noexcept;
|
| 55 |
constexpr bool has_value() const noexcept;
|
| 56 |
constexpr void operator*() const noexcept;
|
| 57 |
+
constexpr void value() const &; // freestanding-deleted
|
| 58 |
+
constexpr void value() &&; // freestanding-deleted
|
| 59 |
constexpr const E& error() const & noexcept;
|
| 60 |
constexpr E& error() & noexcept;
|
| 61 |
constexpr const E&& error() const && noexcept;
|
| 62 |
constexpr E&& error() && noexcept;
|
| 63 |
template<class G = E> constexpr E error_or(G&&) const &;
|
|
|
|
| 94 |
};
|
| 95 |
};
|
| 96 |
```
|
| 97 |
|
| 98 |
Any object of type `expected<T, E>` either represents a value of type
|
| 99 |
+
`T`, or contains a value of type `E` nested within [[intro.object]] it.
|
| 100 |
+
Member *`has_val`* indicates whether the `expected<T, E>` object
|
| 101 |
+
represents a value of type `T`.
|
|
|
|
|
|
|
| 102 |
|
| 103 |
A program that instantiates the definition of the template
|
| 104 |
`expected<T, E>` with a type for the `E` parameter that is not a valid
|
| 105 |
template argument for `unexpected` is ill-formed.
|
| 106 |
|
|
|
|
| 265 |
|
| 266 |
``` cpp
|
| 267 |
constexpr expected& operator=(expected&& rhs) noexcept(see below);
|
| 268 |
```
|
| 269 |
|
| 270 |
+
*Constraints:* `is_move_constructible_v<E>` is `true` and
|
| 271 |
+
`is_move_assignable_v<E>` is `true`.
|
| 272 |
+
|
| 273 |
*Effects:*
|
| 274 |
|
| 275 |
- If `this->has_value() && rhs.has_value()` is `true`, no effects.
|
| 276 |
- Otherwise, if `this->has_value()` is `true`, equivalent to:
|
| 277 |
``` cpp
|
|
|
|
| 285 |
*Returns:* `*this`.
|
| 286 |
|
| 287 |
*Remarks:* The exception specification is equivalent to
|
| 288 |
`is_nothrow_move_constructible_v<E> && is_nothrow_move_assignable_v<E>`.
|
| 289 |
|
|
|
|
|
|
|
|
|
|
| 290 |
``` cpp
|
| 291 |
template<class G>
|
| 292 |
constexpr expected& operator=(const unexpected<G>& e);
|
| 293 |
template<class G>
|
| 294 |
constexpr expected& operator=(unexpected<G>&& e);
|
|
|
|
| 333 |
|
| 334 |
| \topline | `this->has_value()` | `!this->has_value()` |
|
| 335 |
| -------- | ------------------- | -------------------- |
|
| 336 |
|
| 337 |
|
| 338 |
+
For the case where `rhs.has_value()` is `false` and `this->has_value()`
|
| 339 |
+
is `true`, equivalent to:
|
| 340 |
|
| 341 |
``` cpp
|
| 342 |
construct_at(addressof(unex), std::move(rhs.unex));
|
| 343 |
destroy_at(addressof(rhs.unex));
|
| 344 |
has_val = false;
|
|
|
|
| 367 |
|
| 368 |
``` cpp
|
| 369 |
constexpr void operator*() const noexcept;
|
| 370 |
```
|
| 371 |
|
| 372 |
+
`has_value()` is `true`.
|
| 373 |
|
| 374 |
``` cpp
|
| 375 |
constexpr void value() const &;
|
| 376 |
```
|
| 377 |
|
| 378 |
+
*Mandates:* `is_copy_constructible_v<E>` is `true`.
|
| 379 |
+
|
| 380 |
*Throws:* `bad_expected_access(error())` if `has_value()` is `false`.
|
| 381 |
|
| 382 |
``` cpp
|
| 383 |
constexpr void value() &&;
|
| 384 |
```
|
| 385 |
|
| 386 |
+
*Mandates:* `is_copy_constructible_v<E>` is `true` and
|
| 387 |
+
`is_move_constructible_v<E>` is `true`.
|
| 388 |
+
|
| 389 |
*Throws:* `bad_expected_access(std::move(error()))` if `has_value()` is
|
| 390 |
`false`.
|
| 391 |
|
| 392 |
``` cpp
|
| 393 |
constexpr const E& error() const & noexcept;
|
| 394 |
constexpr E& error() & noexcept;
|
| 395 |
```
|
| 396 |
|
| 397 |
+
`has_value()` is `false`.
|
| 398 |
|
| 399 |
*Returns:* *unex*.
|
| 400 |
|
| 401 |
``` cpp
|
| 402 |
constexpr E&& error() && noexcept;
|
| 403 |
constexpr const E&& error() const && noexcept;
|
| 404 |
```
|
| 405 |
|
| 406 |
+
`has_value()` is `false`.
|
| 407 |
|
| 408 |
*Returns:* `std::move(`*`unex`*`)`.
|
| 409 |
|
| 410 |
``` cpp
|
| 411 |
template<class G = E> constexpr E error_or(G&& e) const &;
|
|
|
|
| 437 |
Let `U` be `remove_cvref_t<invoke_result_t<F>>`.
|
| 438 |
|
| 439 |
*Constraints:* `is_constructible_v<E, decltype(error())>>` is `true`.
|
| 440 |
|
| 441 |
*Mandates:* `U` is a specialization of `expected` and
|
| 442 |
+
`is_same_v<typename U::error_type, E>` is `true`.
|
| 443 |
|
| 444 |
*Effects:* Equivalent to:
|
| 445 |
|
| 446 |
``` cpp
|
| 447 |
if (has_value())
|
|
|
|
| 459 |
|
| 460 |
*Constraints:* `is_constructible_v<E, decltype(std::move(error()))>` is
|
| 461 |
`true`.
|
| 462 |
|
| 463 |
*Mandates:* `U` is a specialization of `expected` and
|
| 464 |
+
`is_same_v<typename U::error_type, E>` is `true`.
|
| 465 |
|
| 466 |
*Effects:* Equivalent to:
|
| 467 |
|
| 468 |
``` cpp
|
| 469 |
if (has_value())
|
|
|
|
| 478 |
```
|
| 479 |
|
| 480 |
Let `G` be `remove_cvref_t<invoke_result_t<F, decltype(error())>>`.
|
| 481 |
|
| 482 |
*Mandates:* `G` is a specialization of `expected` and
|
| 483 |
+
`is_same_v<typename G::value_type, T>` is `true`.
|
| 484 |
|
| 485 |
*Effects:* Equivalent to:
|
| 486 |
|
| 487 |
``` cpp
|
| 488 |
if (has_value())
|
|
|
|
| 498 |
|
| 499 |
Let `G` be
|
| 500 |
`remove_cvref_t<invoke_result_t<F, decltype(std::move(error()))>>`.
|
| 501 |
|
| 502 |
*Mandates:* `G` is a specialization of `expected` and
|
| 503 |
+
`is_same_v<typename G::value_type, T>` is `true`.
|
| 504 |
|
| 505 |
*Effects:* Equivalent to:
|
| 506 |
|
| 507 |
``` cpp
|
| 508 |
if (has_value())
|
|
|
|
| 616 |
``` cpp
|
| 617 |
template<class T2, class E2> requires is_void_v<T2>
|
| 618 |
friend constexpr bool operator==(const expected& x, const expected<T2, E2>& y);
|
| 619 |
```
|
| 620 |
|
| 621 |
+
*Constraints:* The expression `x.error() == y.error()` is well-formed
|
| 622 |
+
and its result is convertible to `bool`.
|
| 623 |
|
| 624 |
*Returns:* If `x.has_value()` does not equal `y.has_value()`, `false`;
|
| 625 |
otherwise `x.has_value() || static_cast<bool>(x.error() == y.error())`.
|
| 626 |
|
| 627 |
``` cpp
|
| 628 |
template<class E2>
|
| 629 |
friend constexpr bool operator==(const expected& x, const unexpected<E2>& e);
|
| 630 |
```
|
| 631 |
|
| 632 |
+
*Constraints:* The expression `x.error() == e.error()` is well-formed
|
| 633 |
+
and its result is convertible to `bool`.
|
| 634 |
|
| 635 |
*Returns:*
|
| 636 |
`!x.has_value() && static_cast<bool>(x.error() == e.error())`.
|
| 637 |
|