basic_result.html 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  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_result&lt;T, E, NoValuePolicy&gt; - 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"/>
  7. <link rel="icon" href="../../images/favicon.ico" type="image/ico"/>
  8. <body><div class="spirit-nav">
  9. <a accesskey="p" href="../../reference/types/basic_outcome/as_failure_rvalue.html"><img src="../../images/prev.png" alt="Prev"></a>
  10. <a accesskey="u" href="../../reference/types.html"><img src="../../images/up.png" alt="Up"></a>
  11. <a accesskey="h" href="../../index.html"><img src="../../images/home.png" alt="Home"></a><a accesskey="n" href="../../reference/types/basic_result/default.html"><img src="../../images/next.png" alt="Next"></a></div><div id="content">
  12. <div class="titlepage"><div><div><h1 style="clear: both"><code>basic_result&lt;T, E, NoValuePolicy&gt;</code></h1></div></div></div>
  13. <div class="toc"><dl class="toc">
  14. <dt>
  15. <dd><dl>
  16. <dt>
  17. <dd><dl>
  18. <dt><a href="#design-rationale">Design rationale</a></dt>
  19. <dt><a href="#public-member-type-aliases">Public member type aliases</a></dt>
  20. <dt><a href="#protected-member-predicate-booleans">Protected member predicate booleans</a>
  21. <dd><dl>
  22. <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>
  23. </dl></dd></dt>
  24. <dt><a href="#public-member-functions">Public member functions</a>
  25. <dd><dl>
  26. <dt><a href="#disabling-constructors">Disabling constructors</a></dt>
  27. </dl></dd></dt>
  28. </dl></dd></dt>
  29. </dl></dd></dt>
  30. </dl>
  31. </div>
  32. <p>A sum type carrying either a <code>T</code> or an <code>E</code>, with <code>NoValuePolicy</code> specifying what to do if one tries to read state which isn&rsquo;t there. Either or both of <code>T</code> and <code>E</code> can be <code>void</code> to indicate no value for that state is present. Note that <code>E = void</code> makes basic result into effectively an <code>optional&lt;T&gt;</code>, but with <code>NoValuePolicy</code> configurable behaviour. Detectable using <a href="../../reference/traits/is_basic_result.html" class="api-reference"><code>is_basic_result&lt;T&gt;</code></a>
  33. .</p>
  34. <p><em>Requires</em>: Concept requirements if C++ 20, else static asserted:</p>
  35. <ul>
  36. <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&lt;R&gt;</code></a>
  37. is true for both <code>T</code> and <code>E</code>.</li>
  38. <li>That either <code>E</code> is <code>void</code> or <code>DefaultConstructible</code>.</li>
  39. </ul>
  40. <p><em>Namespace</em>: <code>BOOST_OUTCOME_V2_NAMESPACE</code></p>
  41. <p><em>Header</em>: <code>&lt;boost/outcome/basic_result.hpp&gt;</code></p>
  42. <p><em>Inclusions</em>: The very lightest weight of C and C++ header files:</p>
  43. <ol>
  44. <li><code>&lt;cstdint&gt;</code></li>
  45. <li><code>&lt;initializer_list&gt;</code></li>
  46. <li><code>&lt;iosfwd&gt;</code></li>
  47. <li><code>&lt;new&gt;</code></li>
  48. <li><code>&lt;type_traits&gt;</code></li>
  49. <li>If <a href="../../reference/macros/in_place_type.html" class="api-reference"><code>BOOST_OUTCOME_USE_STD_IN_PLACE_TYPE</code></a>
  50. is <code>1</code>, <code>&lt;utility&gt;</code> (defaults to <code>1</code> for C++ 17 or later only)</li>
  51. <li>If C++ exceptions disabled and <code>BOOST_OUTCOME_DISABLE_EXECINFO</code> undefined only (used to print stack backtraces on &ldquo;exception throw&rdquo;):
  52. <ol>
  53. <li><code>&lt;sal.h&gt;</code> (Windows only)</li>
  54. <li><code>&lt;stddef.h&gt;</code> (Windows only)</li>
  55. <li><code>&lt;string.h&gt;</code> (Windows only)</li>
  56. <li><code>&lt;execinfo.h&gt;</code> (POSIX only)</li>
  57. </ol></li>
  58. <li><code>&lt;cstdio&gt;</code></li>
  59. <li><code>&lt;cstdlib&gt;</code></li>
  60. <li><code>&lt;cassert&gt;</code></li>
  61. </ol>
  62. <p>This very light weight set of inclusion dependencies makes basic result suitable for use in global header files of very large C++ codebases.</p>
  63. <h3 id="design-rationale">Design rationale</h3>
  64. <p>The basic result type is the main workhorse type of the Outcome library, providing a simple sum type with optional values representing success or disappointment. Unlike
  65. <a href="https://wg21.link/P0323" class="api-reference" target="_blank"><i class="fa fa-book" aria-hidden="true"></i> P0323 <code>std::expected&lt;T, E&gt;</code></a>
  66. , Outcome&rsquo;s result type is designed specifically for convenience when implementing failure handling across very large codebases, and it has a number of API differences to facilitate that.</p>
  67. <p>The first major design difference is that basic result models its constructor design on
  68. <a href="https://en.cppreference.com/w/cpp/utility/variant" class="api-reference" target="_blank"><i class="fa fa-book" aria-hidden="true"></i> <code>std::variant&lt;...&gt;</code></a>
  69. , rather than modelling
  70. <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&lt;T&gt;</code></a>
  71. &rsquo;s constructor design like <code>std::expected&lt;T, E&gt;</code> does. This means that basic result will implicitly construct either a <code>T</code> or an <code>E</code> if doing so is unambiguous, same as <code>variant</code> does. Where implicit construction is ambiguous, the implicit constructors disable and a <code>T</code> or <code>E</code> can be specified via <a href="../../reference/types/in_place_type_t.html" class="api-reference"><code>in_place_type_t&lt;T&gt;</code></a>
  72. , or via <a href="../../reference/types/success_type.html" class="api-reference"><code>success_type&lt;T&gt;</code></a>
  73. or <a href="../../reference/traits/is_failure_type.html" class="api-reference"><code>failure_type&lt;T&gt;</code></a>
  74. . We implement a subset of variant&rsquo;s constructors for improved compile time impact, so the implicit and explicit constructor design is split into fixed subsets to reduce SFINAE execution.</p>
  75. <p>The second major design difference is that union storage is NOT used, as it is assumed that <code>sizeof(E)</code> will be small for failure handling. This very considerably reduces load on the compiler, and substantially improves compile times in very large C++ 14 codebases, because copies and moves do not need to jump through complex ceremony in order to implement the never-empty guarantees which would be required in a union storage based implementation (C++ 17 onwards does far fewer copy and move constructor instantiations, but it all adds up &ndash; work avoided is always the fastest).</p>
  76. <h3 id="public-member-type-aliases">Public member type aliases</h3>
  77. <ul>
  78. <li><code>value_type</code> is <code>T</code>.</li>
  79. <li><code>error_type</code> is <code>E</code>.</li>
  80. <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>
  81. <li><code>error_type_if_enabled</code> is <code>E</code> if construction from <code>E</code> is available, else it is a usefully named unusable internal type.</li>
  82. <li><code>rebind&lt;A, B = E, C = NoValuePolicy&gt;</code> is <code>basic_result&lt;A, B, C&gt;</code>.</li>
  83. </ul>
  84. <h3 id="protected-member-predicate-booleans">Protected member predicate booleans</h3>
  85. <ul>
  86. <li><p><code>predicate::constructors_enabled</code> is constexpr boolean true if decayed <code>value_type</code> and decayed <code>error_type</code> are not the same type.</p></li>
  87. <li><p><code>predicate::implicit_constructors_enabled</code> is constexpr boolean true if:</p>
  88. <ol>
  89. <li><code>predicate::constructors_enabled</code> is true.</li>
  90. <li>Trait <a href="../../reference/traits/is_error_type.html" class="api-reference"><code>is_error_type&lt;E&gt;</code></a>
  91. is not true for both decayed <code>value_type</code> and decayed <code>error_type</code> at the same time.</li>
  92. <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&lt;E&gt;</code></a>
  93. 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>
  94. </ol></li>
  95. <li><p><code>predicate::enable_value_converting_constructor&lt;A&gt;</code> is constexpr boolean true if:</p>
  96. <ol>
  97. <li><code>predicate::constructors_enabled</code> is true.</li>
  98. <li>Decayed <code>A</code> is not this <code>basic_result</code> type.</li>
  99. <li><code>predicate::implicit_constructors_enabled</code> is true.</li>
  100. <li>Decayed <code>A</code> is not an <code>in_place_type_t</code>.</li>
  101. <li>Trait <a href="../../reference/traits/is_error_type_enum.html" class="api-reference"><code>is_error_type_enum&lt;E, Enum&gt;</code></a>
  102. is false for <code>error_type</code> and decayed <code>A</code>.</li>
  103. <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>
  104. </ol></li>
  105. <li><p><code>predicate::enable_error_converting_constructor&lt;A&gt;</code> is constexpr boolean true if:</p>
  106. <ol>
  107. <li><code>predicate::constructors_enabled</code> is true.</li>
  108. <li>Decayed <code>A</code> is not this <code>basic_result</code> type.</li>
  109. <li><code>predicate::implicit_constructors_enabled</code> is true.</li>
  110. <li>Decayed <code>A</code> is not an <code>in_place_type_t</code>.</li>
  111. <li>Trait <a href="../../reference/traits/is_error_type_enum.html" class="api-reference"><code>is_error_type_enum&lt;E, Enum&gt;</code></a>
  112. is false for <code>error_type</code> and decayed <code>A</code>.</li>
  113. <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>
  114. </ol></li>
  115. <li><p><code>predicate::enable_error_condition_converting_constructor&lt;ErrorCondEnum&gt;</code> is constexpr boolean true if:</p>
  116. <ol>
  117. <li><code>predicate::constructors_enabled</code> is true.</li>
  118. <li>Decayed <code>ErrorCondEnum</code> is not this <code>basic_result</code> type.</li>
  119. <li>Decayed <code>ErrorCondEnum</code> is not an <code>in_place_type_t</code>.</li>
  120. <li>Trait <a href="../../reference/traits/is_error_type_enum.html" class="api-reference"><code>is_error_type_enum&lt;E, Enum&gt;</code></a>
  121. is true for <code>error_type</code> and decayed <code>ErrorCondEnum</code>.</li>
  122. </ol></li>
  123. <li><p><code>predicate::enable_compatible_conversion&lt;A, B, C&gt;</code> is constexpr boolean true if:</p>
  124. <ol>
  125. <li><code>predicate::constructors_enabled</code> is true.</li>
  126. <li><code>basic_result&lt;A, B, C&gt;</code> is not this <code>basic_result</code> type.</li>
  127. <li><code>A</code> is <code>void</code> OR <code>value_type</code> is explicitly constructible from <code>A</code>.</li>
  128. <li><code>B</code> is <code>void</code> OR <code>error_type</code> is explicitly constructible from <code>B</code>.</li>
  129. </ol></li>
  130. <li><p><code>predicate::enable_make_error_code_compatible_conversion&lt;A, B, C&gt;</code> is constexpr boolean true if:</p>
  131. <ol>
  132. <li><code>predicate::constructors_enabled</code> is true.</li>
  133. <li><code>basic_result&lt;A, B, C&gt;</code> is not this <code>basic_result</code> type.</li>
  134. <li>Trait &#34;/home/travis/build/ned14/boost-outcome/doc/src/content/reference/types/basic_result/_index.md:92:14&#34;: API reference page for &#39;is_error_code_available&lt;E&gt;&#39; not found, please use an identifier wholly contained in a page title
  135. <b>API NOT FOUND IN DOCS <code>is_error_code_available&lt;E&gt;</code></b>
  136. is true for decayed <code>error_type</code>.</li>
  137. <li><code>predicate::enable_compatible_conversion&lt;A, B, C&gt;</code> is not true.</li>
  138. <li><code>A</code> is <code>void</code> OR <code>value_type</code> is explicitly constructible from <code>A</code>.</li>
  139. <li><code>error_type</code> is explicitly constructible from <code>make_error_code(B)</code>.</li>
  140. </ol></li>
  141. <li><p><code>predicate::enable_make_exception_ptr_compatible_conversion&lt;A, B, C&gt;</code> is constexpr boolean true if:</p>
  142. <ol>
  143. <li><code>predicate::constructors_enabled</code> is true.</li>
  144. <li><code>basic_result&lt;A, B, C&gt;</code> is not this <code>basic_result</code> type.</li>
  145. <li>Trait &#34;/home/travis/build/ned14/boost-outcome/doc/src/content/reference/types/basic_result/_index.md:100:14&#34;: API reference page for &#39;is_exception_ptr_available&lt;E&gt;&#39; not found, please use an identifier wholly contained in a page title
  146. <b>API NOT FOUND IN DOCS <code>is_exception_ptr_available&lt;E&gt;</code></b>
  147. is true for decayed <code>error_type</code>.</li>
  148. <li><code>predicate::enable_compatible_conversion&lt;A, B, C&gt;</code> is not true.</li>
  149. <li><code>A</code> is <code>void</code> OR <code>value_type</code> is explicitly constructible from <code>A</code>.</li>
  150. <li><code>error_type</code> is explicitly constructible from <code>make_exception_ptr(B)</code>.</li>
  151. </ol></li>
  152. <li><p><code>predicate::enable_inplace_value_constructor&lt;Args...&gt;</code> is constexpr boolean true if:</p>
  153. <ol>
  154. <li><code>predicate::constructors_enabled</code> is true.</li>
  155. <li><code>value_type</code> is <code>void</code> OR <code>value_type</code> is explicitly constructible from <code>Args...</code>.</li>
  156. </ol></li>
  157. <li><p><code>predicate::enable_inplace_error_constructor&lt;Args...&gt;</code> is constexpr boolean true if:</p>
  158. <ol>
  159. <li><code>predicate::constructors_enabled</code> is true.</li>
  160. <li><code>error_type</code> is <code>void</code> OR <code>error_type</code> is explicitly constructible from <code>Args...</code>.</li>
  161. </ol></li>
  162. <li><p><code>predicate::enable_inplace_value_error_constructor&lt;Args...&gt;</code> is constexpr boolean true if:</p>
  163. <ol>
  164. <li><code>predicate::constructors_enabled</code> is true.</li>
  165. <li><code>predicate::implicit_constructors_enabled</code> is true.</li>
  166. <li>Either, but not both, of <code>value_type</code> is explicitly constructible from <code>Args...</code> or <code>error_type</code> is explicitly constructible from <code>Args...</code>.</li>
  167. </ol></li>
  168. </ul>
  169. <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>
  170. <ul>
  171. <li><del><code>DefaultConstructible</code></del>, always deleted to force user to choose valued or errored for every result instanced.</li>
  172. <li><code>MoveConstructible</code>, if both <code>value_type</code> and <code>error_type</code> implement move constructors.</li>
  173. <li><code>CopyConstructible</code>, if both <code>value_type</code> and <code>error_type</code> implement copy constructors.</li>
  174. <li><code>MoveAssignable</code>, if both <code>value_type</code> and <code>error_type</code> implement move constructors and move assignment.</li>
  175. <li><code>CopyAssignable</code>, if both <code>value_type</code> and <code>error_type</code> implement copy constructors and copy assignment.</li>
  176. <li><code>Destructible</code>.</li>
  177. <li><code>TriviallyCopyable</code>, if both <code>value_type</code> and <code>error_type</code> are trivially copyable.</li>
  178. <li><code>TrivialType</code>, if both <code>value_type</code> and <code>error_type</code> are trivial types.</li>
  179. <li><code>LiteralType</code>, if both <code>value_type</code> and <code>error_type</code> are literal types.</li>
  180. <li><p><code>StandardLayoutType</code>, if both <code>value_type</code> and <code>error_type</code> are standard layout types. If so, layout of <code>basic_result</code> in C is guaranteed to be:</p>
  181. <div class="highlight"><pre class="chroma"><code class="language-c++" data-lang="c++"><span class="k">struct</span> <span class="n">result_layout</span> <span class="p">{</span>
  182. <span class="n">value_type</span> <span class="n">value</span><span class="p">;</span>
  183. <span class="kt">unsigned</span> <span class="kt">int</span> <span class="n">flags</span><span class="p">;</span>
  184. <span class="n">error_type</span> <span class="n">error</span><span class="p">;</span>
  185. <span class="p">};</span>
  186. </code></pre></div></li>
  187. <li><p><code>EqualityComparable</code>, if both <code>value_type</code> and <code>error_type</code> implement equality comparisons with one another.</p></li>
  188. <li><p><del><code>LessThanComparable</code></del>, not implemented due to availability of implicit conversions from <code>value_type</code> and <code>error_type</code>, this can cause major surprise (i.e. hard to diagnose bugs), so we don&rsquo;t implement these at all.
  189. ~ <code>Swappable</code></p></li>
  190. <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>
  191. </ul>
  192. <p>Thus <code>basic_result</code> meets the <code>Regular</code> concept if both <code>value_type</code> and <code>error_type</code> are <code>Regular</code>, except for the lack of a default constructor. Often where one needs a default constructor, wrapping <code>basic_result</code> into
  193. <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&lt;T&gt;</code></a>
  194. will suffice.</p>
  195. <h3 id="public-member-functions">Public member functions</h3>
  196. <h4 id="disabling-constructors">Disabling constructors</h4>
  197. <ol class="children children-li"><li>
  198. <a href="../../reference/types/basic_result/disabling_catchall.html" ><code>basic_result(Args...) = delete</code></a>
  199. <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>
  200. <a href="../../reference/types/basic_result/disabling_implicit_constructor.html" ><code>basic_result(X &amp;&amp;) = delete</code></a>
  201. <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>
  202. <h4 id="copy-and-move-constructors-and-assignment-and-destructor">Copy and move constructors and assignment, and destructor</h4>
  203. <ol class="children children-li"><li>
  204. <a href="../../reference/types/basic_result/default.html" ><code>basic_result() = delete</code></a>
  205. <p>The default constructor (disabled).</p><li>
  206. <a href="../../reference/types/basic_result/move_constructor.html" ><code>basic_result(basic_result &amp;&amp;)</code></a>
  207. <p>Move constructor. Constexpr, triviality and noexcept propagating.</p><li>
  208. <a href="../../reference/types/basic_result/copy_constructor.html" ><code>basic_result(const basic_result &amp;)</code></a>
  209. <p>Copy constructor. Constexpr, triviality and noexcept propagating.</p><li>
  210. <a href="../../reference/types/basic_result/move_assignment.html" ><code>basic_result &amp;operator=(basic_result &amp;&amp;)</code></a>
  211. <p>Move assignment. Constexpr, triviality and noexcept propagating.</p><li>
  212. <a href="../../reference/types/basic_result/copy_assignment.html" ><code>basic_result &amp;operator=(const basic_result &amp;)</code></a>
  213. <p>Copy assignment. Constexpr, triviality and noexcept propagating.</p><li>
  214. <a href="../../reference/types/basic_result/destructor.html" ><code>~basic_result()</code></a>
  215. <p>Destructor. Constexpr, triviality and noexcept propagating.</p></li></ol>
  216. <h4 id="converting-constructors">Converting constructors</h4>
  217. <ol class="children children-li"><li>
  218. <a href="../../reference/types/basic_result/implicit_value_converting_constructor.html" ><code>basic_result(R &amp;&amp;)</code></a>
  219. <p>Implicit <code>value_type</code> constructor. Available if <code>predicate::enable_value_converting_constructor&lt;R&gt;</code> is true. Constexpr, triviality and noexcept propagating.</p><li>
  220. <a href="../../reference/types/basic_result/implicit_error_converting_constructor.html" ><code>basic_result(S &amp;&amp;)</code></a>
  221. <p>Implicit <code>error_type</code> constructor. Available if <code>predicate::enable_error_converting_constructor&lt;S&gt;</code> is true. Constexpr, triviality and noexcept propagating.</p><li>
  222. <a href="../../reference/types/basic_result/implicit_error_condition_converting_constructor.html" ><code>basic_result(ErrorCondEnum &amp;&amp;)</code></a>
  223. <p>Implicit <code>error_type</code> from <code>ErrorCondEnum</code> constructor. Available if <code>predicate::enable_error_condition_converting_constructor&lt;ErrorCondEnum&gt;</code> is true. Constexpr, triviality and noexcept propagating.</p><li>
  224. <a href="../../reference/types/basic_result/explicit_valueorerror_converting_constructor.html" ><code>explicit basic_result(ValueOrError&lt;T, E&gt; &amp;&amp;)</code></a>
  225. <p>Explicit converting constructor from <code>ValueOrError&lt;T, E&gt;</code> concept matching types. Available if <code>convert::value_or_error&lt;&gt;</code> permits it. Constexpr, triviality and noexcept propagating.</p><li>
  226. <a href="../../reference/types/basic_result/explicit_copy_converting_constructor.html" ><code>explicit basic_result(const basic_result&lt;R, S, P&gt; &amp;)</code></a>
  227. <p>Explicit converting copy constructor from compatible <code>basic_result</code>. Available if <code>predicate::enable_compatible_conversion&lt;R, S, P&gt;</code> is true. Constexpr, triviality and noexcept propagating.</p><li>
  228. <a href="../../reference/types/basic_result/explicit_move_converting_constructor.html" ><code>explicit basic_result(basic_result&lt;R, S, P&gt; &amp;&amp;)</code></a>
  229. <p>Explicit converting move constructor from compatible <code>basic_result</code>. Available if <code>predicate::enable_compatible_conversion&lt;R, S, P&gt;</code> is true. Constexpr, triviality and noexcept propagating.</p><li>
  230. <a href="../../reference/types/basic_result/explicit_make_error_code_copy_converting_constructor.html" ><code>explicit basic_result(const basic_result&lt;R, S, P&gt; &amp;)</code></a>
  231. <p>Explicit converting copy constructor from compatible <code>basic_result</code>. Available if <code>predicate::enable_make_error_code_compatible_conversion&lt;R, S, P&gt;</code> is true. Constexpr, triviality and noexcept propagating.</p><li>
  232. <a href="../../reference/types/basic_result/explicit_make_error_code_move_converting_constructor.html" ><code>explicit basic_result(basic_result&lt;R, S, P&gt; &amp;&amp;)</code></a>
  233. <p>Explicit converting move constructor from compatible <code>basic_result</code>. Available if <code>predicate::enable_make_error_code_compatible_conversion&lt;R, S, P&gt;</code> is true. Constexpr, triviality and noexcept propagating.</p><li>
  234. <a href="../../reference/types/basic_result/explicit_make_exception_ptr_copy_converting_constructor.html" ><code>explicit basic_result(const basic_result&lt;R, S, P&gt; &amp;)</code></a>
  235. <p>Explicit converting copy constructor from compatible <code>basic_result</code>. Available if <code>predicate::enable_make_exception_ptr_compatible_conversion&lt;R, S, P&gt;</code> is true. Constexpr, triviality and noexcept propagating.</p><li>
  236. <a href="../../reference/types/basic_result/explicit_make_exception_ptr_move_converting_constructor.html" ><code>explicit basic_result(basic_result&lt;R, S, P&gt; &amp;&amp;)</code></a>
  237. <p>Explicit converting move constructor from compatible <code>basic_result</code>. Available if <code>predicate::enable_make_exception_ptr_compatible_conversion&lt;R, S, P&gt;</code> is true. Constexpr, triviality and noexcept propagating.</p></li></ol>
  238. <h4 id="inplace-constructors">Inplace constructors</h4>
  239. <ol class="children children-li"><li>
  240. <a href="../../reference/types/basic_result/explicit_inplace_value_constructor.html" ><code>explicit basic_result(in_place_type_t&lt;value_type_if_enabled&gt;, Args ...)</code></a>
  241. <p>Explicit inplace value constructor. Available if <code>predicate::enable_inplace_value_constructor&lt;Args ...&gt;</code> is true. Constexpr, triviality and noexcept propagating.</p><li>
  242. <a href="../../reference/types/basic_result/explicit_inplace_value_constructor_il.html" ><code>explicit basic_result(in_place_type_t&lt;value_type_if_enabled&gt;, std::initializer_list&lt;U&gt;, Args ...)</code></a>
  243. <p>Explicit inplace value constructor. Available if <code>predicate::enable_inplace_value_constructor&lt;std::initializer_list&lt;U&gt;, Args ...&gt;</code> is true. Constexpr, triviality and noexcept propagating.</p><li>
  244. <a href="../../reference/types/basic_result/explicit_inplace_error_constructor.html" ><code>explicit basic_result(in_place_type_t&lt;error_type_if_enabled&gt;, Args ...)</code></a>
  245. <p>Explicit inplace error constructor. Available if <code>predicate::enable_inplace_error_constructor&lt;Args ...&gt;</code> is true. Constexpr, triviality and noexcept propagating.</p><li>
  246. <a href="../../reference/types/basic_result/explicit_inplace_error_constructor_il.html" ><code>explicit basic_result(in_place_type_t&lt;error_type_if_enabled&gt;, std::initializer_list&lt;U&gt;, Args ...)</code></a>
  247. <p>Explicit inplace error constructor. Available if <code>predicate::enable_inplace_error_constructor&lt;std::initializer_list&lt;U&gt;, Args ...&gt;</code> is true. Constexpr, triviality and noexcept propagating.</p><li>
  248. <a href="../../reference/types/basic_result/implicit_inplace_value_error_constructor.html" ><code>basic_result(A1 &amp;&amp;, A2 &amp;&amp;, Args ...)</code></a>
  249. <p>Implicit inplace value or error constructor. Available if <code>predicate::enable_inplace_value_error_constructor&lt;A1, A2, Args ...&gt;</code> is true. Constexpr, triviality and noexcept propagating.</p></li></ol>
  250. <h4 id="tagged-constructors">Tagged constructors</h4>
  251. <ol class="children children-li"><li>
  252. <a href="../../reference/types/basic_result/implicit_success_copy_constructor.html" ><code>basic_result(const success_type&lt;T&gt; &amp;)</code></a>
  253. <p>Implicit value-from-success-type-sugar copy constructor. Available if <code>predicate::enable_compatible_conversion&lt;T, void, void&gt;</code> is true, or <code>T</code> is <code>void</code>. Constexpr, triviality and noexcept propagating.</p><li>
  254. <a href="../../reference/types/basic_result/implicit_success_move_constructor.html" ><code>basic_result(success_type&lt;T&gt; &amp;&amp;)</code></a>
  255. <p>Implicit value-from-success-type-sugar move constructor. Available if <code>predicate::enable_compatible_conversion&lt;T, void, void&gt;</code> is true, or <code>T</code> is <code>void</code>. Constexpr, triviality and noexcept propagating.</p><li>
  256. <a href="../../reference/types/basic_result/implicit_failure_copy_constructor.html" ><code>basic_result(const failure_type&lt;T&gt; &amp;)</code></a>
  257. <p>Implicit error-from-failure-type-sugar copy constructor. Available if <code>predicate::enable_compatible_conversion&lt;void, T, void&gt;</code> is true, or <code>T</code> is <code>void</code>. Constexpr, triviality and noexcept propagating.</p><li>
  258. <a href="../../reference/types/basic_result/implicit_failure_move_constructor.html" ><code>basic_result(failure_type&lt;T&gt; &amp;&amp;)</code></a>
  259. <p>Implicit error-from-failure-type-sugar move constructor. Available if <code>predicate::enable_compatible_conversion&lt;void, T, void&gt;</code> is true, or <code>T</code> is <code>void</code>. Constexpr, triviality and noexcept propagating.</p><li>
  260. <a href="../../reference/types/basic_result/implicit_failure_make_error_code_copy_constructor.html" ><code>basic_result(const failure_type&lt;T&gt; &amp;)</code></a>
  261. <p>Implicit error-from-failure-type-sugar copy constructor. Available if <code>predicate::enable_make_error_code_compatible_conversion&lt;void, T, void&gt;</code> is true, or <code>T</code> is <code>void</code>. Constexpr, triviality and noexcept propagating.</p><li>
  262. <a href="../../reference/types/basic_result/implicit_failure_make_error_code_move_constructor.html" ><code>basic_result(failure_type&lt;T&gt; &amp;&amp;)</code></a>
  263. <p>Implicit error-from-failure-type-sugar move constructor. Available if <code>predicate::enable_make_error_code_compatible_conversion&lt;void, T, void&gt;</code> is true, or <code>T</code> is <code>void</code>. Constexpr, triviality and noexcept propagating.</p><li>
  264. <a href="../../reference/types/basic_result/implicit_failure_make_exception_ptr_copy_constructor.html" ><code>basic_result(const failure_type&lt;T&gt; &amp;)</code></a>
  265. <p>Implicit error-from-failure-type-sugar copy constructor. Available if <code>predicate::enable_make_exception_ptr_compatible_conversion&lt;void, T, void&gt;</code> is true, or <code>T</code> is <code>void</code>. Constexpr, triviality and noexcept propagating.</p><li>
  266. <a href="../../reference/types/basic_result/implicit_failure_make_exception_ptr_move_constructor.html" ><code>basic_result(failure_type&lt;T&gt; &amp;&amp;)</code></a>
  267. <p>Implicit error-from-failure-type-sugar move constructor. Available if <code>predicate::enable_make_exception_ptr_compatible_conversion&lt;void, T, void&gt;</code> is true, or <code>T</code> is <code>void</code>. Constexpr, triviality and noexcept propagating.</p></li></ol>
  268. <h4 id="observers">Observers</h4>
  269. <ol class="children children-li"><li>
  270. <a href="../../reference/types/basic_result/operator_bool.html" ><code>explicit operator bool() const noexcept</code></a>
  271. <p>Returns true if a value is present. Constexpr, never throws.</p><li>
  272. <a href="../../reference/types/basic_result/has_value.html" ><code>bool has_value() const noexcept</code></a>
  273. <p>Returns true if a value is present. Constexpr, never throws.</p><li>
  274. <a href="../../reference/types/basic_result/has_error.html" ><code>bool has_error() const noexcept</code></a>
  275. <p>Returns true if an error is present. Constexpr, never throws.</p><li>
  276. <a href="../../reference/types/basic_result/has_exception.html" ><code>bool has_exception() const noexcept</code></a>
  277. <p>Always returns false for <code>basic_result</code>. Constexpr, never throws.</p><li>
  278. <a href="../../reference/types/basic_result/has_failure.html" ><code>bool has_failure() const noexcept</code></a>
  279. <p>Returns true if there is either an error or an exception. Constexpr, never throws.</p><li>
  280. <a href="../../reference/types/basic_result/has_lost_consistency.html" ><code>bool has_lost_consistency() const noexcept</code></a>
  281. <p>Returns true if a preceding swap involving this object failed to preserve the strong guarantee. Constexpr, never throws.</p><li>
  282. <a href="../../reference/types/basic_result/assume_value_lvalue.html" ><code>value_type &amp;assume_value() &amp; noexcept</code></a>
  283. <p>Narrow contract lvalue reference observer of any value present. Constexpr propagating, never throws.</p><li>
  284. <a href="../../reference/types/basic_result/assume_value_lvalue_const.html" ><code>const value_type &amp;assume_value() const &amp; noexcept</code></a>
  285. <p>Narrow contract const lvalue reference observer of any value present. Constexpr propagating, never throws.</p><li>
  286. <a href="../../reference/types/basic_result/assume_value_rvalue.html" ><code>value_type &amp;&amp;assume_value() &amp;&amp; noexcept</code></a>
  287. <p>Narrow contract rvalue reference observer of any value present. Constexpr propagating, never throws.</p><li>
  288. <a href="../../reference/types/basic_result/assume_value_rvalue_const.html" ><code>const value_type &amp;&amp;assume_value() const &amp;&amp; noexcept</code></a>
  289. <p>Narrow contract const rvalue reference observer of any value present. Constexpr propagating, never throws.</p><li>
  290. <a href="../../reference/types/basic_result/value_lvalue.html" ><code>value_type &amp;value() &amp;</code></a>
  291. <p>Wide contract lvalue reference observer of any value present. Constexpr propagating.</p><li>
  292. <a href="../../reference/types/basic_result/value_lvalue_const.html" ><code>const value_type &amp;value() const &amp;</code></a>
  293. <p>Wide contract const lvalue reference observer of any value present. Constexpr propagating.</p><li>
  294. <a href="../../reference/types/basic_result/value_rvalue.html" ><code>value_type &amp;&amp;value() &amp;&amp;</code></a>
  295. <p>Wide contract rvalue reference observer of any value present. Constexpr propagating.</p><li>
  296. <a href="../../reference/types/basic_result/value_rvalue_const.html" ><code>const value_type &amp;&amp;value() const &amp;&amp;</code></a>
  297. <p>Wide contract const rvalue reference observer of any value present. Constexpr propagating.</p><li>
  298. <a href="../../reference/types/basic_result/assume_error_lvalue.html" ><code>error_type &amp;assume_error() &amp; noexcept</code></a>
  299. <p>Narrow contract lvalue reference observer of the stored error. Constexpr propagating, never throws.</p><li>
  300. <a href="../../reference/types/basic_result/assume_error_lvalue_const.html" ><code>const error_type &amp;assume_error() const &amp; noexcept</code></a>
  301. <p>Narrow contract const lvalue reference observer of the stored error. Constexpr propagating, never throws.</p><li>
  302. <a href="../../reference/types/basic_result/assume_error_rvalue.html" ><code>error_type &amp;&amp;assume_error() &amp;&amp; noexcept</code></a>
  303. <p>Narrow contract rvalue reference observer of the stored error. Constexpr propagating, never throws.</p><li>
  304. <a href="../../reference/types/basic_result/assume_error_rvalue_const.html" ><code>const error_type &amp;&amp;assume_error() const &amp;&amp; noexcept</code></a>
  305. <p>Narrow contract const rvalue reference observer of the stored error. Constexpr propagating, never throws.</p><li>
  306. <a href="../../reference/types/basic_result/error_lvalue.html" ><code>error_type &amp;error() &amp;</code></a>
  307. <p>Wide contract lvalue reference observer of the stored error. Constexpr propagating.</p><li>
  308. <a href="../../reference/types/basic_result/error_lvalue_const.html" ><code>const error_type &amp;error() const &amp;</code></a>
  309. <p>Wide contract const lvalue reference observer of the stored error. Constexpr propagating.</p><li>
  310. <a href="../../reference/types/basic_result/error_rvalue.html" ><code>error_type &amp;&amp;error() &amp;&amp;</code></a>
  311. <p>Wide contract rvalue reference observer of the stored error. Constexpr propagating.</p><li>
  312. <a href="../../reference/types/basic_result/error_rvalue_const.html" ><code>const error_type &amp;&amp;error() const &amp;&amp;</code></a>
  313. <p>Wide contract const rvalue reference observer of the stored error. Constexpr propagating.</p><li>
  314. <a href="../../reference/types/basic_result/as_failure_lvalue.html" ><code>auto as_failure() const &amp;</code></a>
  315. <p>Return the output from free function <code>failure()</code> containing a copy of any errored state.</p></li></ol>
  316. <h4 id="modifiers">Modifiers</h4>
  317. <ol class="children children-li"><li>
  318. <a href="../../reference/types/basic_result/swap.html" ><code>void swap(basic_result &amp;)</code></a>
  319. <p>Swap one basic_result with another, with the strong guarantee. Noexcept propagating.</p><li>
  320. <a href="../../reference/types/basic_result/as_failure_rvalue.html" ><code>auto as_failure() &amp;&amp;</code></a>
  321. <p>Return the output from free function <code>failure()</code> containing a move of any errored state.</p></li></ol>
  322. <h4 id="comparisons">Comparisons</h4>
  323. <p>See above for why <code>LessThanComparable</code> is not implemented.</p>
  324. <ol class="children children-li"><li>
  325. <a href="../../reference/types/basic_result/equality_basic_result.html" ><code>bool operator==(const basic_result&lt;A, B, C&gt; &amp;) const</code></a>
  326. <p>Returns true if this result compares equal to the other result. Constexpr and noexcept propagating.</p><li>
  327. <a href="../../reference/types/basic_result/inequality_success_type.html" ><code>bool operator==(const success_type&lt;A&gt; &amp;) const</code></a>
  328. <p>Returns true if this result compares equal to the success type sugar. Constexpr and noexcept propagating.</p><li>
  329. <a href="../../reference/types/basic_result/equality_failure_type.html" ><code>bool operator==(const failure_type&lt;A, void&gt; &amp;) const</code></a>
  330. <p>Returns true if this result compares equal to the failure type sugar. Constexpr and noexcept propagating.</p><li>
  331. <a href="../../reference/types/basic_result/inequality_basic_result.html" ><code>bool operator!=(const basic_result&lt;A, B, C&gt; &amp;) const</code></a>
  332. <p>Returns true if this result does not compare equal to the other result. Constexpr and noexcept propagating.</p><li>
  333. <a href="../../reference/types/basic_result/equality_success_type.html" ><code>bool operator!=(const success_type&lt;A&gt; &amp;) const</code></a>
  334. <p>Returns true if this result does not compare equal to the success type sugar. Constexpr and noexcept propagating.</p><li>
  335. <a href="../../reference/types/basic_result/inequality_failure_type.html" ><code>bool operator!=(const failure_type&lt;A, void&gt; &amp;) const</code></a>
  336. <p>Returns true if this result does not compare equal to the failure type sugar. Constexpr and noexcept propagating.</p></li></ol>
  337. </div><p><small>Last revised: October 11, 2019 at 17:03:05 &#43;0100</small></p>
  338. <hr>
  339. <div class="spirit-nav">
  340. <a accesskey="p" href="../../reference/types/basic_outcome/as_failure_rvalue.html"><img src="../../images/prev.png" alt="Prev"></a>
  341. <a accesskey="u" href="../../reference/types.html"><img src="../../images/up.png" alt="Up"></a>
  342. <a accesskey="h" href="../../index.html"><img src="../../images/home.png" alt="Home"></a><a accesskey="n" href="../../reference/types/basic_result/default.html"><img src="../../images/next.png" alt="Next"></a></div></body>
  343. </html>