tmp/tmp_fs5lhg7/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,139 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#### General <a id="expected.object.general">[[expected.object.general]]</a>
|
| 2 |
+
|
| 3 |
+
``` cpp
|
| 4 |
+
namespace std {
|
| 5 |
+
template<class T, class E>
|
| 6 |
+
class expected {
|
| 7 |
+
public:
|
| 8 |
+
using value_type = T;
|
| 9 |
+
using error_type = E;
|
| 10 |
+
using unexpected_type = unexpected<E>;
|
| 11 |
+
|
| 12 |
+
template<class U>
|
| 13 |
+
using rebind = expected<U, error_type>;
|
| 14 |
+
|
| 15 |
+
// [expected.object.cons], constructors
|
| 16 |
+
constexpr expected();
|
| 17 |
+
constexpr expected(const expected&);
|
| 18 |
+
constexpr expected(expected&&) noexcept(see below);
|
| 19 |
+
template<class U, class G>
|
| 20 |
+
constexpr explicit(see below) expected(const expected<U, G>&);
|
| 21 |
+
template<class U, class G>
|
| 22 |
+
constexpr explicit(see below) expected(expected<U, G>&&);
|
| 23 |
+
|
| 24 |
+
template<class U = T>
|
| 25 |
+
constexpr explicit(see below) expected(U&& v);
|
| 26 |
+
|
| 27 |
+
template<class G>
|
| 28 |
+
constexpr explicit(see below) expected(const unexpected<G>&);
|
| 29 |
+
template<class G>
|
| 30 |
+
constexpr explicit(see below) expected(unexpected<G>&&);
|
| 31 |
+
|
| 32 |
+
template<class... Args>
|
| 33 |
+
constexpr explicit expected(in_place_t, Args&&...);
|
| 34 |
+
template<class U, class... Args>
|
| 35 |
+
constexpr explicit expected(in_place_t, initializer_list<U>, Args&&...);
|
| 36 |
+
template<class... Args>
|
| 37 |
+
constexpr explicit expected(unexpect_t, Args&&...);
|
| 38 |
+
template<class U, class... Args>
|
| 39 |
+
constexpr explicit expected(unexpect_t, initializer_list<U>, Args&&...);
|
| 40 |
+
|
| 41 |
+
// [expected.object.dtor], destructor
|
| 42 |
+
constexpr ~expected();
|
| 43 |
+
|
| 44 |
+
// [expected.object.assign], assignment
|
| 45 |
+
constexpr expected& operator=(const expected&);
|
| 46 |
+
constexpr expected& operator=(expected&&) noexcept(see below);
|
| 47 |
+
template<class U = T> constexpr expected& operator=(U&&);
|
| 48 |
+
template<class G>
|
| 49 |
+
constexpr expected& operator=(const unexpected<G>&);
|
| 50 |
+
template<class G>
|
| 51 |
+
constexpr expected& operator=(unexpected<G>&&);
|
| 52 |
+
|
| 53 |
+
template<class... Args>
|
| 54 |
+
constexpr T& emplace(Args&&...) noexcept;
|
| 55 |
+
template<class U, class... Args>
|
| 56 |
+
constexpr T& emplace(initializer_list<U>, Args&&...) noexcept;
|
| 57 |
+
|
| 58 |
+
// [expected.object.swap], swap
|
| 59 |
+
constexpr void swap(expected&) noexcept(see below);
|
| 60 |
+
friend constexpr void swap(expected& x, expected& y) noexcept(noexcept(x.swap(y)));
|
| 61 |
+
|
| 62 |
+
// [expected.object.obs], observers
|
| 63 |
+
constexpr const T* operator->() const noexcept;
|
| 64 |
+
constexpr T* operator->() noexcept;
|
| 65 |
+
constexpr const T& operator*() const & noexcept;
|
| 66 |
+
constexpr T& operator*() & noexcept;
|
| 67 |
+
constexpr const T&& operator*() const && noexcept;
|
| 68 |
+
constexpr T&& operator*() && noexcept;
|
| 69 |
+
constexpr explicit operator bool() const noexcept;
|
| 70 |
+
constexpr bool has_value() const noexcept;
|
| 71 |
+
constexpr const T& value() const &;
|
| 72 |
+
constexpr T& value() &;
|
| 73 |
+
constexpr const T&& value() const &&;
|
| 74 |
+
constexpr T&& value() &&;
|
| 75 |
+
constexpr const E& error() const & noexcept;
|
| 76 |
+
constexpr E& error() & noexcept;
|
| 77 |
+
constexpr const E&& error() const && noexcept;
|
| 78 |
+
constexpr E&& error() && noexcept;
|
| 79 |
+
template<class U> constexpr T value_or(U&&) const &;
|
| 80 |
+
template<class U> constexpr T value_or(U&&) &&;
|
| 81 |
+
template<class G = E> constexpr E error_or(G&&) const &;
|
| 82 |
+
template<class G = E> constexpr E error_or(G&&) &&;
|
| 83 |
+
|
| 84 |
+
// [expected.object.monadic], monadic operations
|
| 85 |
+
template<class F> constexpr auto and_then(F&& f) &;
|
| 86 |
+
template<class F> constexpr auto and_then(F&& f) &&;
|
| 87 |
+
template<class F> constexpr auto and_then(F&& f) const &;
|
| 88 |
+
template<class F> constexpr auto and_then(F&& f) const &&;
|
| 89 |
+
template<class F> constexpr auto or_else(F&& f) &;
|
| 90 |
+
template<class F> constexpr auto or_else(F&& f) &&;
|
| 91 |
+
template<class F> constexpr auto or_else(F&& f) const &;
|
| 92 |
+
template<class F> constexpr auto or_else(F&& f) const &&;
|
| 93 |
+
template<class F> constexpr auto transform(F&& f) &;
|
| 94 |
+
template<class F> constexpr auto transform(F&& f) &&;
|
| 95 |
+
template<class F> constexpr auto transform(F&& f) const &;
|
| 96 |
+
template<class F> constexpr auto transform(F&& f) const &&;
|
| 97 |
+
template<class F> constexpr auto transform_error(F&& f) &;
|
| 98 |
+
template<class F> constexpr auto transform_error(F&& f) &&;
|
| 99 |
+
template<class F> constexpr auto transform_error(F&& f) const &;
|
| 100 |
+
template<class F> constexpr auto transform_error(F&& f) const &&;
|
| 101 |
+
|
| 102 |
+
// [expected.object.eq], equality operators
|
| 103 |
+
template<class T2, class E2> requires (!is_void_v<T2>)
|
| 104 |
+
friend constexpr bool operator==(const expected& x, const expected<T2, E2>& y);
|
| 105 |
+
template<class T2>
|
| 106 |
+
friend constexpr bool operator==(const expected&, const T2&);
|
| 107 |
+
template<class E2>
|
| 108 |
+
friend constexpr bool operator==(const expected&, const unexpected<E2>&);
|
| 109 |
+
|
| 110 |
+
private:
|
| 111 |
+
bool has_val; // exposition only
|
| 112 |
+
union {
|
| 113 |
+
T val; // exposition only
|
| 114 |
+
E unex; // exposition only
|
| 115 |
+
};
|
| 116 |
+
};
|
| 117 |
+
}
|
| 118 |
+
```
|
| 119 |
+
|
| 120 |
+
Any object of type `expected<T, E>` either contains a value of type `T`
|
| 121 |
+
or a value of type `E` within its own storage. Implementations are not
|
| 122 |
+
permitted to use additional storage, such as dynamic memory, to allocate
|
| 123 |
+
the object of type `T` or the object of type `E`. Member *`has_val`*
|
| 124 |
+
indicates whether the `expected<T, E>` object contains an object of type
|
| 125 |
+
`T`.
|
| 126 |
+
|
| 127 |
+
A type `T` is a *valid value type for `expected`*, if `remove_cv_t<T>`
|
| 128 |
+
is `void` or a complete non-array object type that is not `in_place_t`,
|
| 129 |
+
`unexpect_t`, or a specialization of `unexpected`. A program which
|
| 130 |
+
instantiates class template `expected<T, E>` with an argument `T` that
|
| 131 |
+
is not a valid value type for `expected` is ill-formed. A program that
|
| 132 |
+
instantiates the definition of the template `expected<T, E>` with a type
|
| 133 |
+
for the `E` parameter that is not a valid template argument for
|
| 134 |
+
`unexpected` is ill-formed.
|
| 135 |
+
|
| 136 |
+
When `T` is not cv `void`, it shall meet the *Cpp17Destructible*
|
| 137 |
+
requirements ([[cpp17.destructible]]). `E` shall meet the
|
| 138 |
+
*Cpp17Destructible* requirements.
|
| 139 |
+
|