From Jason Turner

[expected.object.cons]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp2uixdywi/{from.md → to.md} +201 -0
tmp/tmp2uixdywi/{from.md → to.md} RENAMED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #### Constructors <a id="expected.object.cons">[[expected.object.cons]]</a>
2
+
3
+ The exposition-only variable template *`converts-from-any-cvref`*
4
+ defined in [[optional.ctor]] is used by some constructors for
5
+ `expected`.
6
+
7
+ ``` cpp
8
+ constexpr expected();
9
+ ```
10
+
11
+ *Constraints:* `is_default_constructible_v<T>` is `true`.
12
+
13
+ *Effects:* Value-initializes *val*.
14
+
15
+ *Ensures:* `has_value()` is `true`.
16
+
17
+ *Throws:* Any exception thrown by the initialization of *val*.
18
+
19
+ ``` cpp
20
+ constexpr expected(const expected& rhs);
21
+ ```
22
+
23
+ *Effects:* If `rhs.has_value()` is `true`, direct-non-list-initializes
24
+ *val* with `*rhs`. Otherwise, direct-non-list-initializes *unex* with
25
+ `rhs.error()`.
26
+
27
+ *Ensures:* `rhs.has_value() == this->has_value()`.
28
+
29
+ *Throws:* Any exception thrown by the initialization of *val* or *unex*.
30
+
31
+ *Remarks:* This constructor is defined as deleted unless
32
+
33
+ - `is_copy_constructible_v<T>` is `true` and
34
+ - `is_copy_constructible_v<E>` is `true`.
35
+
36
+ This constructor is trivial if
37
+
38
+ - `is_trivially_copy_constructible_v<T>` is `true` and
39
+ - `is_trivially_copy_constructible_v<E>` is `true`.
40
+
41
+ ``` cpp
42
+ constexpr expected(expected&& rhs) noexcept(see below);
43
+ ```
44
+
45
+ *Constraints:*
46
+
47
+ - `is_move_constructible_v<T>` is `true` and
48
+ - `is_move_constructible_v<E>` is `true`.
49
+
50
+ *Effects:* If `rhs.has_value()` is `true`, direct-non-list-initializes
51
+ *val* with `std::move(*rhs)`. Otherwise, direct-non-list-initializes
52
+ *unex* with `std::move(rhs.error())`.
53
+
54
+ *Ensures:* `rhs.has_value()` is unchanged;
55
+ `rhs.has_value() == this->has_value()` is `true`.
56
+
57
+ *Throws:* Any exception thrown by the initialization of *val* or *unex*.
58
+
59
+ *Remarks:* The exception specification is equivalent to
60
+ `is_nothrow_move_constructible_v<T> && is_nothrow_move_constructible_v<E>`.
61
+
62
+ This constructor is trivial if
63
+
64
+ - `is_trivially_move_constructible_v<T>` is `true` and
65
+ - `is_trivially_move_constructible_v<E>` is `true`.
66
+
67
+ ``` cpp
68
+ template<class U, class G>
69
+ constexpr explicit(see below) expected(const expected<U, G>& rhs);
70
+ template<class U, class G>
71
+ constexpr explicit(see below) expected(expected<U, G>&& rhs);
72
+ ```
73
+
74
+ Let:
75
+
76
+ - `UF` be `const U&` for the first overload and `U` for the second
77
+ overload.
78
+ - `GF` be `const G&` for the first overload and `G` for the second
79
+ overload.
80
+
81
+ *Constraints:*
82
+
83
+ - `is_constructible_v<T, UF>` is `true`; and
84
+ - `is_constructible_v<E, GF>` is `true`; and
85
+ - if `T` is not cv `bool`,
86
+ *`converts-from-any-cvref`*`<T, expected<U, G>>` is `false`; and
87
+ - `is_constructible_v<unexpected<E>, expected<U, G>&>` is `false`; and
88
+ - `is_constructible_v<unexpected<E>, expected<U, G>>` is `false`; and
89
+ - `is_constructible_v<unexpected<E>, const expected<U, G>&>` is `false`;
90
+ and
91
+ - `is_constructible_v<unexpected<E>, const expected<U, G>>` is `false`.
92
+
93
+ *Effects:* If `rhs.has_value()`, direct-non-list-initializes *val* with
94
+ `std::forward<UF>(*rhs)`. Otherwise, direct-non-list-initializes *unex*
95
+ with `std::forward<GF>(rhs.error())`.
96
+
97
+ *Ensures:* `rhs.has_value()` is unchanged;
98
+ `rhs.has_value() == this->has_value()` is `true`.
99
+
100
+ *Throws:* Any exception thrown by the initialization of *val* or *unex*.
101
+
102
+ *Remarks:* The expression inside `explicit` is equivalent to
103
+ `!is_convertible_v<UF, T> || !is_convertible_v<GF, E>`.
104
+
105
+ ``` cpp
106
+ template<class U = T>
107
+ constexpr explicit(!is_convertible_v<U, T>) expected(U&& v);
108
+ ```
109
+
110
+ *Constraints:*
111
+
112
+ - `is_same_v<remove_cvref_t<U>, in_place_t>` is `false`; and
113
+ - `is_same_v<expected, remove_cvref_t<U>>` is `false`; and
114
+ - `remove_cvref_t<U>` is not a specialization of `unexpected`; and
115
+ - `is_constructible_v<T, U>` is `true`; and
116
+ - if `T` is cv `bool`, `remove_cvref_t<U>` is not a specialization of
117
+ `expected`.
118
+
119
+ *Effects:* Direct-non-list-initializes *val* with `std::forward<U>(v)`.
120
+
121
+ *Ensures:* `has_value()` is `true`.
122
+
123
+ *Throws:* Any exception thrown by the initialization of *val*.
124
+
125
+ ``` cpp
126
+ template<class G>
127
+ constexpr explicit(!is_convertible_v<const G&, E>) expected(const unexpected<G>& e);
128
+ template<class G>
129
+ constexpr explicit(!is_convertible_v<G, E>) expected(unexpected<G>&& e);
130
+ ```
131
+
132
+ Let `GF` be `const G&` for the first overload and `G` for the second
133
+ overload.
134
+
135
+ *Constraints:* `is_constructible_v<E, GF>` is `true`.
136
+
137
+ *Effects:* Direct-non-list-initializes *unex* with
138
+ `std::forward<GF>(e.error())`.
139
+
140
+ *Ensures:* `has_value()` is `false`.
141
+
142
+ *Throws:* Any exception thrown by the initialization of *unex*.
143
+
144
+ ``` cpp
145
+ template<class... Args>
146
+ constexpr explicit expected(in_place_t, Args&&... args);
147
+ ```
148
+
149
+ *Constraints:* `is_constructible_v<T, Args...>` is `true`.
150
+
151
+ *Effects:* Direct-non-list-initializes *val* with
152
+ `std::forward<Args>(args)...`.
153
+
154
+ *Ensures:* `has_value()` is `true`.
155
+
156
+ *Throws:* Any exception thrown by the initialization of *val*.
157
+
158
+ ``` cpp
159
+ template<class U, class... Args>
160
+ constexpr explicit expected(in_place_t, initializer_list<U> il, Args&&... args);
161
+ ```
162
+
163
+ *Constraints:* `is_constructible_v<T, initializer_list<U>&, Args...>` is
164
+ `true`.
165
+
166
+ *Effects:* Direct-non-list-initializes *val* with
167
+ `il, std::forward<Args>(args)...`.
168
+
169
+ *Ensures:* `has_value()` is `true`.
170
+
171
+ *Throws:* Any exception thrown by the initialization of *val*.
172
+
173
+ ``` cpp
174
+ template<class... Args>
175
+ constexpr explicit expected(unexpect_t, Args&&... args);
176
+ ```
177
+
178
+ *Constraints:* `is_constructible_v<E, Args...>` is `true`.
179
+
180
+ *Effects:* Direct-non-list-initializes *unex* with
181
+ `std::forward<Args>(args)...`.
182
+
183
+ *Ensures:* `has_value()` is `false`.
184
+
185
+ *Throws:* Any exception thrown by the initialization of *unex*.
186
+
187
+ ``` cpp
188
+ template<class U, class... Args>
189
+ constexpr explicit expected(unexpect_t, initializer_list<U> il, Args&&... args);
190
+ ```
191
+
192
+ *Constraints:* `is_constructible_v<E, initializer_list<U>&, Args...>` is
193
+ `true`.
194
+
195
+ *Effects:* Direct-non-list-initializes *unex* with
196
+ `il, std::forward<Args>(args)...`.
197
+
198
+ *Ensures:* `has_value()` is `false`.
199
+
200
+ *Throws:* Any exception thrown by the initialization of *unex*.
201
+