tmp/tmpw4qz2q_9/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,140 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
### Class template `unexpected` <a id="expected.unexpected">[[expected.unexpected]]</a>
|
| 2 |
+
|
| 3 |
+
#### General <a id="expected.un.general">[[expected.un.general]]</a>
|
| 4 |
+
|
| 5 |
+
Subclause [[expected.unexpected]] describes the class template
|
| 6 |
+
`unexpected` that represents unexpected objects stored in `expected`
|
| 7 |
+
objects.
|
| 8 |
+
|
| 9 |
+
``` cpp
|
| 10 |
+
namespace std {
|
| 11 |
+
template<class E>
|
| 12 |
+
class unexpected {
|
| 13 |
+
public:
|
| 14 |
+
// [expected.un.cons], constructors
|
| 15 |
+
constexpr unexpected(const unexpected&) = default;
|
| 16 |
+
constexpr unexpected(unexpected&&) = default;
|
| 17 |
+
template<class Err = E>
|
| 18 |
+
constexpr explicit unexpected(Err&&);
|
| 19 |
+
template<class... Args>
|
| 20 |
+
constexpr explicit unexpected(in_place_t, Args&&...);
|
| 21 |
+
template<class U, class... Args>
|
| 22 |
+
constexpr explicit unexpected(in_place_t, initializer_list<U>, Args&&...);
|
| 23 |
+
|
| 24 |
+
constexpr unexpected& operator=(const unexpected&) = default;
|
| 25 |
+
constexpr unexpected& operator=(unexpected&&) = default;
|
| 26 |
+
|
| 27 |
+
constexpr const E& error() const & noexcept;
|
| 28 |
+
constexpr E& error() & noexcept;
|
| 29 |
+
constexpr const E&& error() const && noexcept;
|
| 30 |
+
constexpr E&& error() && noexcept;
|
| 31 |
+
|
| 32 |
+
constexpr void swap(unexpected& other) noexcept(see below);
|
| 33 |
+
|
| 34 |
+
template<class E2>
|
| 35 |
+
friend constexpr bool operator==(const unexpected&, const unexpected<E2>&);
|
| 36 |
+
|
| 37 |
+
friend constexpr void swap(unexpected& x, unexpected& y) noexcept(noexcept(x.swap(y)));
|
| 38 |
+
|
| 39 |
+
private:
|
| 40 |
+
E unex; // exposition only
|
| 41 |
+
};
|
| 42 |
+
|
| 43 |
+
template<class E> unexpected(E) -> unexpected<E>;
|
| 44 |
+
}
|
| 45 |
+
```
|
| 46 |
+
|
| 47 |
+
A program that instantiates the definition of `unexpected` for a
|
| 48 |
+
non-object type, an array type, a specialization of `unexpected`, or a
|
| 49 |
+
cv-qualified type is ill-formed.
|
| 50 |
+
|
| 51 |
+
#### Constructors <a id="expected.un.cons">[[expected.un.cons]]</a>
|
| 52 |
+
|
| 53 |
+
``` cpp
|
| 54 |
+
template<class Err = E>
|
| 55 |
+
constexpr explicit unexpected(Err&& e);
|
| 56 |
+
```
|
| 57 |
+
|
| 58 |
+
*Constraints:*
|
| 59 |
+
|
| 60 |
+
- `is_same_v<remove_cvref_t<Err>, unexpected>` is `false`; and
|
| 61 |
+
- `is_same_v<remove_cvref_t<Err>, in_place_t>` is `false`; and
|
| 62 |
+
- `is_constructible_v<E, Err>` is `true`.
|
| 63 |
+
|
| 64 |
+
*Effects:* Direct-non-list-initializes *unex* with
|
| 65 |
+
`std::forward<Err>(e)`.
|
| 66 |
+
|
| 67 |
+
*Throws:* Any exception thrown by the initialization of *unex*.
|
| 68 |
+
|
| 69 |
+
``` cpp
|
| 70 |
+
template<class... Args>
|
| 71 |
+
constexpr explicit unexpected(in_place_t, Args&&... args);
|
| 72 |
+
```
|
| 73 |
+
|
| 74 |
+
*Constraints:* `is_constructible_v<E, Args...>` is `true`.
|
| 75 |
+
|
| 76 |
+
*Effects:* Direct-non-list-initializes *unex* with
|
| 77 |
+
`std::forward<Args>(args)...`.
|
| 78 |
+
|
| 79 |
+
*Throws:* Any exception thrown by the initialization of *unex*.
|
| 80 |
+
|
| 81 |
+
``` cpp
|
| 82 |
+
template<class U, class... Args>
|
| 83 |
+
constexpr explicit unexpected(in_place_t, initializer_list<U> il, Args&&... args);
|
| 84 |
+
```
|
| 85 |
+
|
| 86 |
+
*Constraints:* `is_constructible_v<E, initializer_list<U>&, Args...>` is
|
| 87 |
+
`true`.
|
| 88 |
+
|
| 89 |
+
*Effects:* Direct-non-list-initializes *unex* with
|
| 90 |
+
`il, std::forward<Args>(args)...`.
|
| 91 |
+
|
| 92 |
+
*Throws:* Any exception thrown by the initialization of *unex*.
|
| 93 |
+
|
| 94 |
+
#### Observers <a id="expected.un.obs">[[expected.un.obs]]</a>
|
| 95 |
+
|
| 96 |
+
``` cpp
|
| 97 |
+
constexpr const E& error() const & noexcept;
|
| 98 |
+
constexpr E& error() & noexcept;
|
| 99 |
+
```
|
| 100 |
+
|
| 101 |
+
*Returns:* *unex*.
|
| 102 |
+
|
| 103 |
+
``` cpp
|
| 104 |
+
constexpr E&& error() && noexcept;
|
| 105 |
+
constexpr const E&& error() const && noexcept;
|
| 106 |
+
```
|
| 107 |
+
|
| 108 |
+
*Returns:* `std::move(`*`unex`*`)`.
|
| 109 |
+
|
| 110 |
+
#### Swap <a id="expected.un.swap">[[expected.un.swap]]</a>
|
| 111 |
+
|
| 112 |
+
``` cpp
|
| 113 |
+
constexpr void swap(unexpected& other) noexcept(is_nothrow_swappable_v<E>);
|
| 114 |
+
```
|
| 115 |
+
|
| 116 |
+
*Mandates:* `is_swappable_v<E>` is `true`.
|
| 117 |
+
|
| 118 |
+
*Effects:* Equivalent to:
|
| 119 |
+
`using std::swap; swap(`*`unex`*`, other.`*`unex`*`);`
|
| 120 |
+
|
| 121 |
+
``` cpp
|
| 122 |
+
friend constexpr void swap(unexpected& x, unexpected& y) noexcept(noexcept(x.swap(y)));
|
| 123 |
+
```
|
| 124 |
+
|
| 125 |
+
*Constraints:* `is_swappable_v<E>` is `true`.
|
| 126 |
+
|
| 127 |
+
*Effects:* Equivalent to `x.swap(y)`.
|
| 128 |
+
|
| 129 |
+
#### Equality operator <a id="expected.un.eq">[[expected.un.eq]]</a>
|
| 130 |
+
|
| 131 |
+
``` cpp
|
| 132 |
+
template<class E2>
|
| 133 |
+
friend constexpr bool operator==(const unexpected& x, const unexpected<E2>& y);
|
| 134 |
+
```
|
| 135 |
+
|
| 136 |
+
*Mandates:* The expression `x.error() == y.error()` is well-formed and
|
| 137 |
+
its result is convertible to `bool`.
|
| 138 |
+
|
| 139 |
+
*Returns:* `x.error() == y.error()`.
|
| 140 |
+
|