From Jason Turner

[expected.void.general]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpbo1h8nay/{from.md → to.md} +109 -0
tmp/tmpbo1h8nay/{from.md → to.md} RENAMED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #### General <a id="expected.void.general">[[expected.void.general]]</a>
2
+
3
+ ``` cpp
4
+ template<class T, class E> requires is_void_v<T>
5
+ class expected<T, E> {
6
+ public:
7
+ using value_type = T;
8
+ using error_type = E;
9
+ using unexpected_type = unexpected<E>;
10
+
11
+ template<class U>
12
+ using rebind = expected<U, error_type>;
13
+
14
+ // [expected.void.cons], constructors
15
+ constexpr expected() noexcept;
16
+ constexpr expected(const expected&);
17
+ constexpr expected(expected&&) noexcept(see below);
18
+ template<class U, class G>
19
+ constexpr explicit(see below) expected(const expected<U, G>&);
20
+ template<class U, class G>
21
+ constexpr explicit(see below) expected(expected<U, G>&&);
22
+
23
+ template<class G>
24
+ constexpr explicit(see below) expected(const unexpected<G>&);
25
+ template<class G>
26
+ constexpr explicit(see below) expected(unexpected<G>&&);
27
+
28
+ constexpr explicit expected(in_place_t) noexcept;
29
+ template<class... Args>
30
+ constexpr explicit expected(unexpect_t, Args&&...);
31
+ template<class U, class... Args>
32
+ constexpr explicit expected(unexpect_t, initializer_list<U>, Args&&...);
33
+
34
+
35
+ // [expected.void.dtor], destructor
36
+ constexpr ~expected();
37
+
38
+ // [expected.void.assign], assignment
39
+ constexpr expected& operator=(const expected&);
40
+ constexpr expected& operator=(expected&&) noexcept(see below);
41
+ template<class G>
42
+ constexpr expected& operator=(const unexpected<G>&);
43
+ template<class G>
44
+ constexpr expected& operator=(unexpected<G>&&);
45
+ constexpr void emplace() noexcept;
46
+
47
+ // [expected.void.swap], swap
48
+ constexpr void swap(expected&) noexcept(see below);
49
+ friend constexpr void swap(expected& x, expected& y) noexcept(noexcept(x.swap(y)));
50
+
51
+ // [expected.void.obs], observers
52
+ constexpr explicit operator bool() const noexcept;
53
+ constexpr bool has_value() const noexcept;
54
+ constexpr void operator*() const noexcept;
55
+ constexpr void value() const &;
56
+ constexpr void value() &&;
57
+ constexpr const E& error() const & noexcept;
58
+ constexpr E& error() & noexcept;
59
+ constexpr const E&& error() const && noexcept;
60
+ constexpr E&& error() && noexcept;
61
+ template<class G = E> constexpr E error_or(G&&) const &;
62
+ template<class G = E> constexpr E error_or(G&&) &&;
63
+
64
+ // [expected.void.monadic], monadic operations
65
+ template<class F> constexpr auto and_then(F&& f) &;
66
+ template<class F> constexpr auto and_then(F&& f) &&;
67
+ template<class F> constexpr auto and_then(F&& f) const &;
68
+ template<class F> constexpr auto and_then(F&& f) const &&;
69
+ template<class F> constexpr auto or_else(F&& f) &;
70
+ template<class F> constexpr auto or_else(F&& f) &&;
71
+ template<class F> constexpr auto or_else(F&& f) const &;
72
+ template<class F> constexpr auto or_else(F&& f) const &&;
73
+ template<class F> constexpr auto transform(F&& f) &;
74
+ template<class F> constexpr auto transform(F&& f) &&;
75
+ template<class F> constexpr auto transform(F&& f) const &;
76
+ template<class F> constexpr auto transform(F&& f) const &&;
77
+ template<class F> constexpr auto transform_error(F&& f) &;
78
+ template<class F> constexpr auto transform_error(F&& f) &&;
79
+ template<class F> constexpr auto transform_error(F&& f) const &;
80
+ template<class F> constexpr auto transform_error(F&& f) const &&;
81
+
82
+ // [expected.void.eq], equality operators
83
+ template<class T2, class E2> requires is_void_v<T2>
84
+ friend constexpr bool operator==(const expected& x, const expected<T2, E2>& y);
85
+ template<class E2>
86
+ friend constexpr bool operator==(const expected&, const unexpected<E2>&);
87
+
88
+ private:
89
+ bool has_val; // exposition only
90
+ union {
91
+ E unex; // exposition only
92
+ };
93
+ };
94
+ ```
95
+
96
+ Any object of type `expected<T, E>` either represents a value of type
97
+ `T`, or contains a value of type `E` within its own storage.
98
+ Implementations are not permitted to use additional storage, such as
99
+ dynamic memory, to allocate the object of type `E`. Member *`has_val`*
100
+ indicates whether the `expected<T, E>` object represents a value of type
101
+ `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
+
107
+ `E` shall meet the requirements of *Cpp17Destructible* (
108
+ [[cpp17.destructible]]).
109
+