1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2 <html><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
3 <title>basic_outcome<T, EC, EP, NoValuePolicy> - Boost.Outcome documentation</title>
4 <link rel="stylesheet" href="../../css/boost.css" type="text/css">
5 <meta name="generator" content="Hugo 0.52 with Boostdoc theme">
6 <meta name="viewport" content="width=device-width,initial-scale=1.0"/>
8 <link rel="icon" href="../../images/favicon.ico" type="image/ico"/>
9 <body><div class="spirit-nav">
10 <a accesskey="p" href="../../reference/types.html"><img src="../../images/prev.png" alt="Prev"></a>
11 <a accesskey="u" href="../../reference/types.html"><img src="../../images/up.png" alt="Up"></a>
12 <a accesskey="h" href="../../index.html"><img src="../../images/home.png" alt="Home"></a><a accesskey="n" href="../../reference/types/basic_outcome/default.html"><img src="../../images/next.png" alt="Next"></a></div><div id="content">
14 <div class="titlepage"><div><div><h1 style="clear: both"><code>basic_outcome<T, EC, EP, NoValuePolicy></code></h1></div></div></div>
15 <div class="toc"><dl class="toc">
20 <dt><a href="#design-rationale">Design rationale</a></dt>
21 <dt><a href="#public-member-type-aliases">Public member type aliases</a></dt>
22 <dt><a href="#protected-member-predicate-booleans">Protected member predicate booleans</a>
24 <dt><a href="#summary-of-standard-requirements-provided-https-en-cppreference-com-w-cpp-named-req">Summary of <a href="https://en.cppreference.com/w/cpp/named_req">standard requirements provided</a></a></dt>
26 <dt><a href="#public-member-functions">Public member functions</a>
28 <dt><a href="#disabling-constructors">Disabling constructors</a></dt>
36 <p>A type carrying one of (i) a successful <code>T</code> (ii) a disappointment <code>EC</code> (iii) a failure <code>EP</code> (iv) both a disappointment <code>EC</code> and a failure <code>EP</code>, with <code>NoValuePolicy</code> specifying what to do if one tries to read state which isn’t there. Any one, two, or all of <code>T</code>, <code>EC</code> and <code>EP</code> can be <code>void</code> to indicate no value for that state is present. Detectable using <a href="../../reference/traits/is_basic_outcome.html" class="api-reference"><code>is_basic_outcome<T></code></a>
39 <p><em>Requires</em>: Concept requirements if C++ 20, else static asserted:</p>
42 <li>That trait <a href="../../reference/traits/type_can_be_used_in_basic_result.html" class="api-reference"><code>type_can_be_used_in_basic_result<R></code></a>
43 is true for <code>T</code>, <code>EC</code> and <code>EP</code>.</li>
44 <li>That either <code>EC</code> is <code>void</code> or <code>DefaultConstructible</code>.</li>
45 <li>That either <code>EP</code> is <code>void</code> or <code>DefaultConstructible</code>.</li>
48 <p><em>Namespace</em>: <code>BOOST_OUTCOME_V2_NAMESPACE</code></p>
50 <p><em>Header</em>: <code><boost/outcome/basic_outcome.hpp></code></p>
52 <p><em>Inclusions</em>: The very lightest weight of C and C++ header files:</p>
55 <li><code><cstdint></code></li>
56 <li><code><initializer_list></code></li>
57 <li><code><iosfwd></code></li>
58 <li><code><new></code></li>
59 <li><code><type_traits></code></li>
60 <li>If <a href="../../reference/macros/in_place_type.html" class="api-reference"><code>BOOST_OUTCOME_USE_STD_IN_PLACE_TYPE</code></a>
61 is <code>1</code>, <code><utility></code> (defaults to <code>1</code> for C++ 17 or later only)</li>
62 <li>If C++ exceptions disabled and <code>BOOST_OUTCOME_DISABLE_EXECINFO</code> undefined only (used to print stack backtraces on “exception throw”):
65 <li><code><sal.h></code> (Windows only)</li>
66 <li><code><stddef.h></code> (Windows only)</li>
67 <li><code><string.h></code> (Windows only)</li>
68 <li><code><execinfo.h></code> (POSIX only)</li>
70 <li><code><cstdio></code></li>
71 <li><code><cstdlib></code></li>
72 <li><code><cassert></code></li>
75 <p>This very light weight set of inclusion dependencies makes basic outcome suitable for use in global header files of very large C++ codebases.</p>
77 <h3 id="design-rationale">Design rationale</h3>
79 <p><code>basic_outcome</code> extends <a href="../../reference/types/basic_result.html" class="api-reference"><code>basic_result<T, E, NoValuePolicy></code></a>
80 with a third state to transport,
81 conventionally (but not necessarily) some sort of “abort” or “exceptional” state which a function can
82 return to indicate that not only did the operation fail, but it did so <em>catastrophically</em> i.e. please
83 abort any attempt to retry the operation.</p>
85 <p>A perfect alternative is to throw a C++ exception for the abort code path, and indeed most programs
86 ought to do exactly that instead of using <code>basic_outcome</code>. However there are a number of use cases
87 where choosing <code>basic_outcome</code> shines:</p>
90 <li>Where C++ exceptions or RTTI is not available, but the ability to fail catastrophically without
91 terminating the program is important.</li>
92 <li>Where deterministic behaviour is required even in the catastrophic failure situation.</li>
93 <li>In unit test suites of code using Outcome it is extremely convenient to accumulate test failures
94 into a <code>basic_outcome</code> for later reporting. A similar convenience applies to RPC situations, where
95 C++ exception throws need to be accumulated for reporting back to the initiating endpoint.</li>
96 <li>Where a function is “dual use deterministic” i.e. it can be used deterministically, in which case
97 one switches control flow based on <code>.error()</code>, or it can be used non-deterministically by throwing
98 an exception perhaps carrying a custom payload.</li>
101 <h3 id="public-member-type-aliases">Public member type aliases</h3>
104 <li><code>value_type</code> is <code>T</code>.</li>
105 <li><code>error_type</code> is <code>EC</code>.</li>
106 <li><code>exception_type</code> is <code>EP</code>.</li>
107 <li><code>value_type_if_enabled</code> is <code>T</code> if construction from <code>T</code> is available, else it is a usefully named unusable internal type.</li>
108 <li><code>error_type_if_enabled</code> is <code>EC</code> if construction from <code>EC</code> is available, else it is a usefully named unusable internal type.</li>
109 <li><code>exception_type_if_enabled</code> is <code>EP</code> if construction from <code>EP</code> is available, else it is a usefully named unusable internal type.</li>
110 <li><code>rebind<A, B = EC, C = EP, D = NoValuePolicy></code> is <code>basic_outcome<A, B, C, D></code>.</li>
113 <h3 id="protected-member-predicate-booleans">Protected member predicate booleans</h3>
116 <li><p><code>predicate::constructors_enabled</code> is constexpr boolean true if:</p>
119 <li>Decayed <code>value_type</code> and decayed <code>error_type</code> are not the same type, or both are <code>void</code>.</li>
120 <li>Decayed <code>value_type</code> and decayed <code>exception_type</code> are not the same type, or both are <code>void</code>.</li>
121 <li>Decayed <code>error_type</code> and decayed <code>exception_type</code> are not the same type, or both are <code>void</code>.</li>
124 <li><p><code>predicate::implicit_constructors_enabled</code> is constexpr boolean true if:</p>
127 <li><code>predicate::constructors_enabled</code> is true.</li>
128 <li>Trait <a href="../../reference/traits/is_error_type.html" class="api-reference"><code>is_error_type<E></code></a>
129 is not true for both decayed <code>value_type</code> and decayed <code>error_type</code> at the same time.</li>
130 <li><code>value_type</code> is not implicitly constructible from <code>error_type</code> and <code>error_type</code> is not implicitly constructible from <code>value_type</code>.<br>OR<br>trait <a href="../../reference/traits/is_error_type.html" class="api-reference"><code>is_error_type<E></code></a>
131 is true for decayed <code>error_type</code> and <code>error_type</code> is not implicitly constructible from <code>value_type</code> and <code>value_type</code> is an integral type.</li>
132 <li><code>value_type</code> is not implicitly constructible from <code>exception_type</code>.</li>
133 <li><code>error_type</code> is not implicitly constructible from <code>exception_type</code>.</li>
134 <li><code>exception_type</code> is not implicitly constructible from <code>value_type</code>.</li>
135 <li><code>exception_type</code> is not implicitly constructible from <code>error_type</code>.</li>
138 <li><p><code>predicate::enable_value_converting_constructor<A></code> is constexpr boolean true if:</p>
141 <li><code>predicate::constructors_enabled</code> is true.</li>
142 <li>Decayed <code>A</code> is not this <code>basic_outcome</code> type.</li>
143 <li><code>predicate::implicit_constructors_enabled</code> is true.</li>
144 <li>Decayed <code>A</code> is not an <code>in_place_type_t</code>.</li>
145 <li>Trait <a href="../../reference/traits/is_error_type_enum.html" class="api-reference"><code>is_error_type_enum<E, Enum></code></a>
146 is false for <code>error_type</code> and decayed <code>A</code>.</li>
147 <li><code>value_type</code> is implicitly constructible from <code>A</code> and <code>error_type</code> is not implicitly constructible from <code>A</code>.<br>OR<br><code>value_type</code> is the exact same type as decayed <code>A</code> and <code>value_type</code> is implicitly constructible from <code>A</code>.</li>
148 <li><code>exception_type</code> is not implicitly constructible from <code>A</code>.</li>
151 <li><p><code>predicate::enable_error_converting_constructor<A></code> is constexpr boolean true if:</p>
154 <li><code>predicate::constructors_enabled</code> is true.</li>
155 <li>Decayed <code>A</code> is not this <code>basic_outcome</code> type.</li>
156 <li><code>predicate::implicit_constructors_enabled</code> is true.</li>
157 <li>Decayed <code>A</code> is not an <code>in_place_type_t</code>.</li>
158 <li>Trait <a href="../../reference/traits/is_error_type_enum.html" class="api-reference"><code>is_error_type_enum<E, Enum></code></a>
159 is false for <code>error_type</code> and decayed <code>A</code>.</li>
160 <li><code>value_type</code> is not implicitly constructible from <code>A</code> and <code>error_type</code> is implicitly constructible from <code>A</code>.<br>OR<br><code>error_type</code> is the exact same type as decayed <code>A</code> and <code>error_type</code> is implicitly constructible from <code>A</code>.</li>
161 <li><code>exception_type</code> is not implicitly constructible from <code>A</code>.</li>
164 <li><p><code>predicate::enable_error_condition_converting_constructor<ErrorCondEnum></code> is constexpr boolean true if:</p>
167 <li><code>predicate::constructors_enabled</code> is true.</li>
168 <li>Decayed <code>ErrorCondEnum</code> is not this <code>basic_outcome</code> type.</li>
169 <li>Decayed <code>ErrorCondEnum</code> is not an <code>in_place_type_t</code>.</li>
170 <li>Trait <a href="../../reference/traits/is_error_type_enum.html" class="api-reference"><code>is_error_type_enum<E, Enum></code></a>
171 is true for <code>error_type</code> and decayed <code>ErrorCondEnum</code>.</li>
172 <li><code>exception_type</code> is not implicitly constructible from <code>ErrorCondEnum</code>.</li>
175 <li><p><code>predicate::enable_exception_converting_constructor<A></code> is constexpr boolean true if:</p>
178 <li><code>predicate::constructors_enabled</code> is true.</li>
179 <li>Decayed <code>A</code> is not this <code>basic_outcome</code> type.</li>
180 <li><code>predicate::implicit_constructors_enabled</code> is true.</li>
181 <li>Decayed <code>A</code> is not an <code>in_place_type_t</code>.</li>
182 <li><code>value_type</code> is not implicitly constructible from <code>A</code>.</li>
183 <li><code>error_type</code> is not implicitly constructible from <code>A</code>.</li>
184 <li><code>exception_type</code> is implicitly constructible from <code>A</code>.</li>
187 <li><p><code>predicate::enable_error_exception_converting_constructor<A, B></code> is constexpr boolean true if:</p>
190 <li><code>predicate::constructors_enabled</code> is true.</li>
191 <li>Decayed <code>A</code> is not this <code>basic_outcome</code> type.</li>
192 <li><code>predicate::implicit_constructors_enabled</code> is true.</li>
193 <li>Decayed <code>A</code> is not an <code>in_place_type_t</code>.</li>
194 <li><code>value_type</code> is not implicitly constructible from <code>A</code>.</li>
195 <li><code>error_type</code> is implicitly constructible from <code>A</code>.</li>
196 <li><code>value_type</code> is not implicitly constructible from <code>B</code>.</li>
197 <li><code>exception_type</code> is implicitly constructible from <code>B</code>.</li>
200 <li><p><code>predicate::enable_compatible_conversion<A, B, C, D></code> is constexpr boolean true if:</p>
203 <li><code>predicate::constructors_enabled</code> is true.</li>
204 <li><code>basic_outcome<A, B, C, D></code> is not this <code>basic_outcome</code> type.</li>
205 <li><code>A</code> is <code>void</code> OR <code>value_type</code> is explicitly constructible from <code>A</code>.</li>
206 <li><code>B</code> is <code>void</code> OR <code>error_type</code> is explicitly constructible from <code>B</code>.</li>
207 <li><code>C</code> is <code>void</code> OR <code>exception_type</code> is explicitly constructible from <code>C</code>.</li>
210 <li><p><code>predicate::enable_make_error_code_compatible_conversion<A, B, C, D></code> is constexpr boolean true if:</p>
213 <li><code>predicate::constructors_enabled</code> is true.</li>
214 <li><code>basic_outcome<A, B, C, D></code> is not this <code>basic_outcome</code> type.</li>
215 <li>Trait "/home/travis/build/ned14/boost-outcome/doc/src/content/reference/types/basic_outcome/_index.md:138:14": API reference page for 'is_error_code_available<E>' not found, please use an identifier wholly contained in a page title
216 <b>API NOT FOUND IN DOCS <code>is_error_code_available<E></code></b>
217 is true for decayed <code>error_type</code>.</li>
218 <li><code>predicate::enable_compatible_conversion<A, B, C, D></code> is not true.</li>
219 <li><code>A</code> is <code>void</code> OR <code>value_type</code> is explicitly constructible from <code>A</code>.</li>
220 <li><code>error_type</code> is explicitly constructible from <code>make_error_code(B)</code>.</li>
221 <li><code>C</code> is <code>void</code> OR <code>exception_type</code> is explicitly constructible from <code>C</code>.</li>
224 <li><p><code>predicate::enable_inplace_value_constructor<Args...></code> is constexpr boolean true if:</p>
227 <li><code>predicate::constructors_enabled</code> is true.</li>
228 <li><code>value_type</code> is <code>void</code> OR <code>value_type</code> is explicitly constructible from <code>Args...</code>.</li>
231 <li><p><code>predicate::enable_inplace_error_constructor<Args...></code> is constexpr boolean true if:</p>
234 <li><code>predicate::constructors_enabled</code> is true.</li>
235 <li><code>error_type</code> is <code>void</code> OR <code>error_type</code> is explicitly constructible from <code>Args...</code>.</li>
238 <li><p><code>predicate::enable_inplace_exception_constructor<Args...></code> is constexpr boolean true if:</p>
241 <li><code>predicate::constructors_enabled</code> is true.</li>
242 <li><code>exception_type</code> is <code>void</code> OR <code>exception_type</code> is explicitly constructible from <code>Args...</code>.</li>
245 <li><p><code>predicate::enable_inplace_value_error_exception_constructor<Args...></code> is constexpr boolean true if:</p>
248 <li><code>predicate::constructors_enabled</code> is true.</li>
249 <li><code>predicate::implicit_constructors_enabled</code> is true.</li>
250 <li>Exactly one of <code>value_type</code> is explicitly constructible from <code>Args...</code>, or <code>error_type</code> is explicitly constructible from <code>Args...</code>, or <code>exception_type</code> is explicitly constructible
251 from <code>Args...</code>.</li>
255 <h4 id="summary-of-standard-requirements-provided-https-en-cppreference-com-w-cpp-named-req">Summary of <a href="https://en.cppreference.com/w/cpp/named_req">standard requirements provided</a></h4>
258 <li><del><code>DefaultConstructible</code></del>, always deleted to force user to choose valued or errored or excepted for every outcome instanced.</li>
259 <li><code>MoveConstructible</code>, if all of <code>value_type</code>, <code>error_type</code> and <code>exception_type</code> implement move constructors.</li>
260 <li><code>CopyConstructible</code>, if all of <code>value_type</code>, <code>error_type</code> and <code>exception_type</code> implement copy constructors.</li>
261 <li><code>MoveAssignable</code>, if all of <code>value_type</code>, <code>error_type</code> and <code>exception_type</code> implement move constructors and move assignment.</li>
262 <li><code>CopyAssignable</code>, if all of <code>value_type</code>, <code>error_type</code> and <code>exception_type</code> implement copy constructors and copy assignment.</li>
263 <li><code>Destructible</code>.</li>
264 <li><code>TriviallyCopyable</code>, if all of <code>value_type</code>, <code>error_type</code> and <code>exception_type</code> are trivially copyable.</li>
265 <li><code>TrivialType</code>, if all of <code>value_type</code>, <code>error_type</code> and <code>exception_type</code> are trivial types.</li>
266 <li><code>LiteralType</code>, if all of <code>value_type</code>, <code>error_type</code> and <code>exception_type</code> are literal types.</li>
268 <li><p><del><code>StandardLayoutType</code></del>. It is implementation defined if <code>basic_outcome</code> can be used by C.
269 However all of the three major compilers MSVC, GCC and clang implement C layout of <code>basic_outcome</code> as follows:</p>
270 <div class="highlight"><pre class="chroma"><code class="language-c++" data-lang="c++"><span class="k">struct</span> <span class="n">outcome_layout</span> <span class="p">{</span>
271 <span class="k">struct</span> <span class="n">result_layout</span> <span class="p">{</span>
272 <span class="n">value_type</span> <span class="n">value</span><span class="p">;</span>
273 <span class="kt">unsigned</span> <span class="kt">int</span> <span class="n">flags</span><span class="p">;</span>
274 <span class="n">error_type</span> <span class="n">error</span><span class="p">;</span>
275 <span class="p">};</span>
276 <span class="n">exception_type</span> <span class="n">exception</span><span class="p">;</span>
277 <span class="p">};</span>
279 <p>If you choose standard layout <code>value_type</code>, <code>error_type</code> and <code>exception_type</code>, <code>basic_outcome</code>
280 works fine from C on MSVC, GCC and clang.</p></li>
282 <li><p><code>EqualityComparable</code>, if all of <code>value_type</code>, <code>error_type</code> and <code>exception_type</code> implement equality comparisons with one another.</p></li>
284 <li><p><del><code>LessThanComparable</code></del>, not implemented due to availability of implicit conversions from <code>value_type</code>, <code>error_type</code> and <code>exception_type</code>, this can cause major surprise (i.e. hard to diagnose bugs), so we don’t implement these at all.
285 ~ <code>Swappable</code></p></li>
287 <li><p><del><code>Hash</code></del>, not implemented as a generic implementation of a unique hash for non-valued items which are unequal would require a dependency on RTTI being enabled.</p></li>
290 <p>Thus <code>basic_outcome</code> meets the <code>Regular</code> concept if all of <code>value_type</code>, <code>error_type</code> and <code>exception_type</code> are <code>Regular</code>, except for the lack of a default constructor. Often where one needs a default constructor, wrapping <code>basic_outcome</code> into
291 <a href="https://en.cppreference.com/w/cpp/utility/optional" class="api-reference" target="_blank"><i class="fa fa-book" aria-hidden="true"></i> <code>std::optional<T></code></a>
294 <h3 id="public-member-functions">Public member functions</h3>
296 <h4 id="disabling-constructors">Disabling constructors</h4>
298 <ol class="children children-li"><li>
299 <a href="../../reference/types/basic_outcome/disabling_catchall.html" ><code>basic_outcome(Args...) = delete</code></a>
300 <p>Disabling catchall constructor used to give useful diagnostic error when trying to use non-inplace constructors when <code>predicate::constructors_enabled</code> is false.</p><li>
301 <a href="../../reference/types/basic_outcome/disabling_implicit_constructor.html" ><code>basic_outcome(X &&) = delete</code></a>
302 <p>Disabling implicit constructor used to give useful diagnostic error when trying to use implicit constructors when <code>predicate::implicit_constructors_enabled</code> is false.</p></li></ol>
304 <h4 id="copy-and-move-constructors-and-assignment-and-destructor">Copy and move constructors and assignment, and destructor</h4>
306 <ol class="children children-li"><li>
307 <a href="../../reference/types/basic_outcome/default.html" ><code>basic_outcome() = delete</code></a>
308 <p>The default constructor (disabled).</p><li>
309 <a href="../../reference/types/basic_outcome/move_constructor.html" ><code>basic_outcome(basic_outcome &&)</code></a>
310 <p>Move constructor. Constexpr, triviality and noexcept propagating.</p><li>
311 <a href="../../reference/types/basic_outcome/copy_constructor.html" ><code>basic_outcome(const basic_outcome &)</code></a>
312 <p>Copy constructor. Constexpr, triviality and noexcept propagating.</p><li>
313 <a href="../../reference/types/basic_outcome/move_assignment.html" ><code>basic_outcome &operator=(basic_outcome &&)</code></a>
314 <p>Move assignment. Constexpr, triviality and noexcept propagating.</p><li>
315 <a href="../../reference/types/basic_outcome/copy_assignment.html" ><code>basic_outcome &operator=(const basic_outcome &)</code></a>
316 <p>Copy assignment. Constexpr, triviality and noexcept propagating.</p><li>
317 <a href="../../reference/types/basic_outcome/destructor.html" ><code>~basic_outcome()</code></a>
318 <p>Destructor. Constexpr, triviality and noexcept propagating.</p></li></ol>
320 <h4 id="converting-constructors">Converting constructors</h4>
322 <ol class="children children-li"><li>
323 <a href="../../reference/types/basic_outcome/implicit_value_converting_constructor.html" ><code>basic_outcome(R &&)</code></a>
324 <p>Implicit <code>value_type</code> constructor. Available if <code>predicate::enable_value_converting_constructor<R></code> is true. Constexpr, triviality and noexcept propagating.</p><li>
325 <a href="../../reference/types/basic_outcome/implicit_error_converting_constructor.html" ><code>basic_outcome(S &&)</code></a>
326 <p>Implicit <code>error_type</code> constructor. Available if <code>predicate::enable_error_converting_constructor<S></code> is true. Constexpr, triviality and noexcept propagating.</p><li>
327 <a href="../../reference/types/basic_outcome/implicit_error_condition_converting_constructor.html" ><code>basic_outcome(ErrorCondEnum &&)</code></a>
328 <p>Implicit <code>error_type</code> from <code>ErrorCondEnum</code> constructor. Available if <code>predicate::enable_error_condition_converting_constructor<ErrorCondEnum></code> is true. Constexpr, triviality and noexcept propagating.</p><li>
329 <a href="../../reference/types/basic_outcome/implicit_exception_converting_constructor.html" ><code>basic_outcome(P &&)</code></a>
330 <p>Implicit <code>exception_type</code> constructor. Available if <code>predicate::enable_exception_converting_constructor<P></code> is true. Constexpr, triviality and noexcept propagating.</p><li>
331 <a href="../../reference/types/basic_outcome/implicit_error_exception_converting_constructor.html" ><code>basic_outcome(S &&, P &&)</code></a>
332 <p>Implicit <code>error_type</code> + <code>exception_type</code> constructor. Available if <code>predicate::enable_error_exception_converting_constructor<S, P></code> is true. Constexpr, triviality and noexcept propagating.</p><li>
333 <a href="../../reference/types/basic_outcome/explicit_valueorerror_converting_constructor.html" ><code>explicit basic_outcome(ValueOrError<T, E> &&)</code></a>
334 <p>Explicit converting constructor from <code>ValueOrError<T, E></code> concept matching types. Available if <code>convert::value_or_error<></code> permits it. Constexpr, triviality and noexcept propagating.</p><li>
335 <a href="../../reference/types/basic_outcome/explicit_copy_converting_constructor.html" ><code>explicit basic_outcome(const basic_outcome<A, B, C, D> &)</code></a>
336 <p>Explicit converting copy constructor from compatible <code>basic_outcome</code>. Available if <code>predicate::enable_compatible_conversion<A, B, C, D></code> is true. Constexpr, triviality and noexcept propagating.</p><li>
337 <a href="../../reference/types/basic_outcome/explicit_move_converting_constructor.html" ><code>explicit basic_outcome(basic_outcome<A, B, C, D> &&)</code></a>
338 <p>Explicit converting move constructor from compatible <code>basic_outcome</code>. Available if <code>predicate::enable_compatible_conversion<A, B, C, D></code> is true. Constexpr, triviality and noexcept propagating.</p><li>
339 <a href="../../reference/types/basic_outcome/explicit_result_copy_converting_constructor.html" ><code>explicit basic_outcome(const basic_result<A, B, C> &)</code></a>
340 <p>Explicit converting copy constructor from compatible <code>basic_result</code>. Available if <code>predicate::enable_compatible_conversion<A, B, void, C></code> is true. Constexpr, triviality and noexcept propagating.</p><li>
341 <a href="../../reference/types/basic_outcome/explicit_result_move_converting_constructor.html" ><code>explicit basic_outcome(basic_result<A, B, C> &&)</code></a>
342 <p>Explicit converting move constructor from compatible <code>basic_result</code>. Available if <code>predicate::enable_compatible_conversion<A, B, void, C></code> is true. Constexpr, triviality and noexcept propagating.</p><li>
343 <a href="../../reference/types/basic_outcome/explicit_result_make_error_code_copy_converting_constructor.html" ><code>explicit basic_outcome(const basic_result<A, B, C> &)</code></a>
344 <p>Explicit converting copy constructor from compatible <code>basic_result</code>. Available if <code>predicate::enable_make_error_code_compatible_conversion<A, B, void, C></code> is true. Constexpr, triviality and noexcept propagating.</p><li>
345 <a href="../../reference/types/basic_outcome/explicit_result_make_error_code_move_converting_constructor.html" ><code>explicit basic_outcome(basic_result<A, B, C> &&)</code></a>
346 <p>Explicit converting move constructor from compatible <code>basic_result</code>. Available if <code>predicate::enable_make_error_code_compatible_conversion<A, B, void, C></code> is true. Constexpr, triviality and noexcept propagating.</p></li></ol>
348 <h4 id="inplace-constructors">Inplace constructors</h4>
350 <ol class="children children-li"><li>
351 <a href="../../reference/types/basic_outcome/explicit_inplace_value_constructor.html" ><code>explicit basic_outcome(in_place_type_t<value_type_if_enabled>, Args ...)</code></a>
352 <p>Explicit inplace value constructor. Available if <code>predicate::enable_inplace_value_constructor<Args ...></code> is true. Constexpr, triviality and noexcept propagating.</p><li>
353 <a href="../../reference/types/basic_outcome/explicit_inplace_value_constructor_il.html" ><code>explicit basic_outcome(in_place_type_t<value_type_if_enabled>, std::initializer_list<U>, Args ...)</code></a>
354 <p>Explicit inplace value constructor. Available if <code>predicate::enable_inplace_value_constructor<std::initializer_list<U>, Args ...></code> is true. Constexpr, triviality and noexcept propagating.</p><li>
355 <a href="../../reference/types/basic_outcome/explicit_inplace_error_constructor.html" ><code>explicit basic_outcome(in_place_type_t<error_type_if_enabled>, Args ...)</code></a>
356 <p>Explicit inplace error constructor. Available if <code>predicate::enable_inplace_error_constructor<Args ...></code> is true. Constexpr, triviality and noexcept propagating.</p><li>
357 <a href="../../reference/types/basic_outcome/explicit_inplace_error_constructor_il.html" ><code>explicit basic_outcome(in_place_type_t<error_type_if_enabled>, std::initializer_list<U>, Args ...)</code></a>
358 <p>Explicit inplace error constructor. Available if <code>predicate::enable_inplace_error_constructor<std::initializer_list<U>, Args ...></code> is true. Constexpr, triviality and noexcept propagating.</p><li>
359 <a href="../../reference/types/basic_outcome/explicit_inplace_exception_constructor.html" ><code>explicit basic_outcome(in_place_type_t<exception_type_if_enabled>, Args ...)</code></a>
360 <p>Explicit inplace exception constructor. Available if <code>predicate::enable_inplace_exception_constructor<Args ...></code> is true. Constexpr, triviality and noexcept propagating.</p><li>
361 <a href="../../reference/types/basic_outcome/explicit_inplace_exception_constructor_il.html" ><code>explicit basic_outcome(in_place_type_t<exception_type_if_enabled>, std::initializer_list<U>, Args ...)</code></a>
362 <p>Explicit inplace exception constructor. Available if <code>predicate::enable_inplace_exception_constructor<std::initializer_list<U>, Args ...></code> is true. Constexpr, triviality and noexcept propagating.</p><li>
363 <a href="../../reference/types/basic_outcome/implicit_inplace_value_error_exception_constructor.html" ><code>basic_outcome(A1 &&, A2 &&, Args ...)</code></a>
364 <p>Implicit inplace value or error or exception constructor. Available if <code>predicate::enable_inplace_value_error_exception_constructor<A1, A2, Args ...></code> is true. Constexpr, triviality and noexcept propagating.</p></li></ol>
366 <h4 id="tagged-constructors">Tagged constructors</h4>
368 <ol class="children children-li"><li>
369 <a href="../../reference/types/basic_outcome/implicit_success_copy_constructor.html" ><code>basic_outcome(const success_type<T> &)</code></a>
370 <p>Implicit value-from-success-type-sugar copy constructor. Available if <code>predicate::enable_compatible_conversion<T, void, void></code> is true, or <code>T</code> is <code>void</code>. Constexpr, triviality and noexcept propagating.</p><li>
371 <a href="../../reference/types/basic_outcome/implicit_success_move_constructor.html" ><code>basic_outcome(success_type<T> &&)</code></a>
372 <p>Implicit value-from-success-type-sugar move constructor. Available if <code>predicate::enable_compatible_conversion<T, void, void></code> is true, or <code>T</code> is <code>void</code>. Constexpr, triviality and noexcept propagating.</p><li>
373 <a href="../../reference/types/basic_outcome/implicit_failure_error_copy_constructor.html" ><code>basic_outcome(const failure_type<EC> &)</code></a>
374 <p>Implicit error-from-failure-type-sugar copy constructor. Available if <code>predicate::enable_compatible_conversion<void, EC, void, void></code> is true. Constexpr, triviality and noexcept propagating.</p><li>
375 <a href="../../reference/types/basic_outcome/implicit_failure_error_move_constructor.html" ><code>basic_outcome(failure_type<EC> &&)</code></a>
376 <p>Implicit error-from-failure-type-sugar move constructor. Available if <code>predicate::enable_compatible_conversion<void, EC, void, void></code> is true. Constexpr, triviality and noexcept propagating.</p><li>
377 <a href="../../reference/types/basic_outcome/implicit_failure_error_make_error_code_copy_constructor.html" ><code>basic_outcome(const failure_type<EC> &)</code></a>
378 <p>Implicit error-from-failure-type-sugar copy constructor. Available if <code>predicate::enable_make_error_code_compatible_conversion<void, EC, void, void></code> is true. Constexpr, triviality and noexcept propagating.</p><li>
379 <a href="../../reference/types/basic_outcome/implicit_failure_error_make_error_code_move_constructor.html" ><code>basic_outcome(failure_type<EC> &&)</code></a>
380 <p>Implicit error-from-failure-type-sugar move constructor. Available if <code>predicate::enable_make_error_code_compatible_conversion<void, EC, void, void></code> is true. Constexpr, triviality and noexcept propagating.</p><li>
381 <a href="../../reference/types/basic_outcome/implicit_failure_exception_copy_constructor.html" ><code>basic_outcome(const failure_type<EP> &)</code></a>
382 <p>Implicit exception-from-failure-type-sugar copy constructor. Available if <code>predicate::enable_compatible_conversion<void, void, EP, void></code> is true. Constexpr, triviality and noexcept propagating.</p><li>
383 <a href="../../reference/types/basic_outcome/implicit_failure_exception_move_constructor.html" ><code>basic_outcome(failure_type<EP> &&)</code></a>
384 <p>Implicit exception-from-failure-type-sugar move constructor. Available if <code>predicate::enable_compatible_conversion<void, void, EP, void></code> is true. Constexpr, triviality and noexcept propagating.</p><li>
385 <a href="../../reference/types/basic_outcome/implicit_failure_error_exception_copy_constructor.html" ><code>basic_outcome(const failure_type<EC, EP> &)</code></a>
386 <p>Implicit error-and-exception-from-failure-type-sugar copy constructor. Available if <code>predicate::enable_compatible_conversion<void, EC, EP, void></code> is true. Constexpr, triviality and noexcept propagating.</p><li>
387 <a href="../../reference/types/basic_outcome/implicit_failure_error_exception_move_constructor.html" ><code>basic_outcome(failure_type<EC, EP> &&)</code></a>
388 <p>Implicit error-and-exception-from-failure-type-sugar move constructor. Available if <code>predicate::enable_compatible_conversion<void, EC, EP, void></code> is true. Constexpr, triviality and noexcept propagating.</p></li></ol>
390 <h4 id="observers">Observers</h4>
392 <ol class="children children-li"><li>
393 <a href="../../reference/types/basic_outcome/operator_bool.html" ><code>explicit operator bool() const noexcept</code></a>
394 <p>Returns true if a value is present. Constexpr, never throws.</p><li>
395 <a href="../../reference/types/basic_outcome/has_value.html" ><code>bool has_value() const noexcept</code></a>
396 <p>Returns true if a value is present. Constexpr, never throws.</p><li>
397 <a href="../../reference/types/basic_outcome/has_error.html" ><code>bool has_error() const noexcept</code></a>
398 <p>Returns true if an error is present. Constexpr, never throws.</p><li>
399 <a href="../../reference/types/basic_outcome/has_exception.html" ><code>bool has_exception() const noexcept</code></a>
400 <p>Returns true if an exception is present. Constexpr, never throws.</p><li>
401 <a href="../../reference/types/basic_outcome/has_failure.html" ><code>bool has_failure() const noexcept</code></a>
402 <p>Returns true if there is either an error or an exception. Constexpr, never throws.</p><li>
403 <a href="../../reference/types/basic_outcome/assume_value_lvalue.html" ><code>value_type &assume_value() & noexcept</code></a>
404 <p>Narrow contract lvalue reference observer of any value present. Constexpr propagating, never throws.</p><li>
405 <a href="../../reference/types/basic_outcome/assume_value_lvalue_const.html" ><code>const value_type &assume_value() const & noexcept</code></a>
406 <p>Narrow contract const lvalue reference observer of any value present. Constexpr propagating, never throws.</p><li>
407 <a href="../../reference/types/basic_outcome/assume_value_rvalue.html" ><code>value_type &&assume_value() && noexcept</code></a>
408 <p>Narrow contract rvalue reference observer of any value present. Constexpr propagating, never throws.</p><li>
409 <a href="../../reference/types/basic_outcome/assume_value_rvalue_const.html" ><code>const value_type &&assume_value() const && noexcept</code></a>
410 <p>Narrow contract const rvalue reference observer of any value present. Constexpr propagating, never throws.</p><li>
411 <a href="../../reference/types/basic_outcome/value_lvalue.html" ><code>value_type &value() &</code></a>
412 <p>Wide contract lvalue reference observer of any value present. Constexpr propagating.</p><li>
413 <a href="../../reference/types/basic_outcome/value_lvalue_const.html" ><code>const value_type &value() const &</code></a>
414 <p>Wide contract const lvalue reference observer of any value present. Constexpr propagating.</p><li>
415 <a href="../../reference/types/basic_outcome/value_rvalue.html" ><code>value_type &&value() &&</code></a>
416 <p>Wide contract rvalue reference observer of any value present. Constexpr propagating.</p><li>
417 <a href="../../reference/types/basic_outcome/value_rvalue_const.html" ><code>const value_type &&value() const &&</code></a>
418 <p>Wide contract const rvalue reference observer of any value present. Constexpr propagating.</p><li>
419 <a href="../../reference/types/basic_outcome/assume_error_lvalue.html" ><code>error_type &assume_error() & noexcept</code></a>
420 <p>Narrow contract lvalue reference observer of the stored error. Constexpr propagating, never throws.</p><li>
421 <a href="../../reference/types/basic_outcome/assume_error_lvalue_const.html" ><code>const error_type &assume_error() const & noexcept</code></a>
422 <p>Narrow contract const lvalue reference observer of the stored error. Constexpr propagating, never throws.</p><li>
423 <a href="../../reference/types/basic_outcome/assume_error_rvalue.html" ><code>error_type &&assume_error() && noexcept</code></a>
424 <p>Narrow contract rvalue reference observer of the stored error. Constexpr propagating, never throws.</p><li>
425 <a href="../../reference/types/basic_outcome/assume_error_rvalue_const.html" ><code>const error_type &&assume_error() const && noexcept</code></a>
426 <p>Narrow contract const rvalue reference observer of the stored error. Constexpr propagating, never throws.</p><li>
427 <a href="../../reference/types/basic_outcome/error_lvalue.html" ><code>error_type &error() &</code></a>
428 <p>Wide contract lvalue reference observer of the stored error. Constexpr propagating.</p><li>
429 <a href="../../reference/types/basic_outcome/error_lvalue_const.html" ><code>const error_type &error() const &</code></a>
430 <p>Wide contract const lvalue reference observer of the stored error. Constexpr propagating.</p><li>
431 <a href="../../reference/types/basic_outcome/error_rvalue.html" ><code>error_type &&error() &&</code></a>
432 <p>Wide contract rvalue reference observer of the stored error. Constexpr propagating.</p><li>
433 <a href="../../reference/types/basic_outcome/error_rvalue_const.html" ><code>const error_type &&error() const &&</code></a>
434 <p>Wide contract const rvalue reference observer of the stored error. Constexpr propagating.</p><li>
435 <a href="../../reference/types/basic_outcome/assume_exception_lvalue.html" ><code>exception_type &assume_exception() & noexcept</code></a>
436 <p>Narrow contract lvalue reference observer of the stored exception. Constexpr propagating, never throws.</p><li>
437 <a href="../../reference/types/basic_outcome/assume_exception_lvalue_const.html" ><code>const exception_type &assume_exception() const & noexcept</code></a>
438 <p>Narrow contract const lvalue reference observer of the stored exception. Constexpr propagating, never throws.</p><li>
439 <a href="../../reference/types/basic_outcome/assume_exception_rvalue_const.html" ><code>const exception_type &&assume_exception() const && noexcept</code></a>
440 <p>Narrow contract const rvalue reference observer of the stored exception. Constexpr propagating, never throws.</p><li>
441 <a href="../../reference/types/basic_outcome/assume_exception_rvalue.html" ><code>exception_type &&assume_exception() && noexcept</code></a>
442 <p>Narrow contract rvalue reference observer of the stored exception. Constexpr propagating, never throws.</p><li>
443 <a href="../../reference/types/basic_outcome/exception_lvalue.html" ><code>exception_type &exception() &</code></a>
444 <p>Wide contract lvalue reference observer of the stored exception. Constexpr propagating.</p><li>
445 <a href="../../reference/types/basic_outcome/exception_lvalue_const.html" ><code>const exception_type &exception() const &</code></a>
446 <p>Wide contract const lvalue reference observer of the stored exception. Constexpr propagating.</p><li>
447 <a href="../../reference/types/basic_outcome/exception_rvalue.html" ><code>exception_type &&exception() &&</code></a>
448 <p>Wide contract rvalue reference observer of the stored exception. Constexpr propagating.</p><li>
449 <a href="../../reference/types/basic_outcome/exception_rvalue_const.html" ><code>const exception_type &&exception() const &&</code></a>
450 <p>Wide contract const rvalue reference observer of the stored exception. Constexpr propagating.</p><li>
451 <a href="../../reference/types/basic_outcome/failure.html" ><code>exception_type failure() const noexcept</code></a>
452 <p>Synthesising observer of the stored exception or error. Available if the traits <code>is_error_code_available<T></code> and <code>is_exception_ptr_available<T></code> are both true. Never throws.</p><li>
453 <a href="../../reference/types/basic_outcome/as_failure_lvalue.html" ><code>failure_type<error_type, exception_type> as_failure() const &</code></a>
454 <p>Return the output from free function <code>failure()</code> containing a copy of any errored and/or excepted state.</p></li></ol>
456 <h4 id="modifiers">Modifiers</h4>
458 <ol class="children children-li"><li>
459 <a href="../../reference/types/basic_outcome/swap.html" ><code>void swap(basic_outcome &)</code></a>
460 <p>Swap one basic_outcome with another, with the strong guarantee. Noexcept propagating.</p><li>
461 <a href="../../reference/types/basic_outcome/as_failure_rvalue.html" ><code>failure_type<error_type, exception_type> as_failure() &&</code></a>
462 <p>Return the output from free function <code>failure()</code> containing a move of any errored and/or excepted state.</p></li></ol>
464 <h4 id="comparisons">Comparisons</h4>
466 <p>See above for why <code>LessThanComparable</code> is not implemented.</p>
468 <ol class="children children-li"><li>
469 <a href="../../reference/types/basic_outcome/equality_basic_result.html" ><code>bool operator==(const basic_result<A, B, C> &) const</code></a>
470 <p>Returns true if this outcome compares equal to the other result. Constexpr and noexcept propagating.</p><li>
471 <a href="../../reference/types/basic_outcome/equality_basic_outcome.html" ><code>bool operator==(const basic_outcome<A, B, C, D> &) const</code></a>
472 <p>Returns true if this outcome compares equal to the other outcome. Constexpr and noexcept propagating.</p><li>
473 <a href="../../reference/types/basic_outcome/inequality_success_type.html" ><code>bool operator==(const success_type<A> &) const</code></a>
474 <p>Returns true if this result compares equal to the success type sugar. Constexpr and noexcept propagating.</p><li>
475 <a href="../../reference/types/basic_outcome/equality_failure_type.html" ><code>bool operator==(const failure_type<A, B> &) const</code></a>
476 <p>Returns true if this outcome compares equal to the failure type sugar. Constexpr and noexcept propagating.</p><li>
477 <a href="../../reference/types/basic_outcome/inequality_basic_result.html" ><code>bool operator!=(const basic_result<A, B, C> &) const</code></a>
478 <p>Returns true if this outcome does not compare equal to the other result. Constexpr and noexcept propagating.</p><li>
479 <a href="../../reference/types/basic_outcome/inequality_basic_outcome.html" ><code>bool operator!=(const basic_outcome<A, B, C, D> &) const</code></a>
480 <p>Returns true if this outcome does not compare equal to the other outcome. Constexpr and noexcept propagating.</p><li>
481 <a href="../../reference/types/basic_outcome/equality_success_type.html" ><code>bool operator!=(const success_type<A> &) const</code></a>
482 <p>Returns true if this outcome does not compare equal to the success type sugar. Constexpr and noexcept propagating.</p><li>
483 <a href="../../reference/types/basic_outcome/inequality_failure_type.html" ><code>bool operator!=(const failure_type<A, B> &) const</code></a>
484 <p>Returns true if this outcome does not compare equal to the failure type sugar. Constexpr and noexcept propagating.</p></li></ol>
492 </div><p><small>Last revised: October 11, 2019 at 17:03:05 +0100</small></p>
494 <div class="spirit-nav">
495 <a accesskey="p" href="../../reference/types.html"><img src="../../images/prev.png" alt="Prev"></a>
496 <a accesskey="u" href="../../reference/types.html"><img src="../../images/up.png" alt="Up"></a>
497 <a accesskey="h" href="../../index.html"><img src="../../images/home.png" alt="Home"></a><a accesskey="n" href="../../reference/types/basic_outcome/default.html"><img src="../../images/next.png" alt="Next"></a></div></body>