failure.html 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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>auto failure(T &amp;&amp;, &hellip;) - 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/functions/policy/outcome_throw_as_system_error_with_payload_std_error_code.html"><img src="../../images/prev.png" alt="Prev"></a>
  10. <a accesskey="u" href="../../reference/functions.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/functions/success.html"><img src="../../images/next.png" alt="Next"></a></div><div id="content">
  12. <div class="titlepage"><div><div><h1 style="clear: both"><code>auto failure(T &amp;&amp;, ...)</code></h1></div></div></div>
  13. <p>Returns appropriate type sugar for constructing an unsuccessful result or outcome, usually <a href="../../reference/types/failure_type.html" class="api-reference"><code>failure_type&lt;EC, EP = void&gt;</code></a>
  14. with a decayed <code>T</code>.</p>
  15. <p>Two default overloads are provided, one taking a single parameter returning <code>failure_type&lt;std::decay_t&lt;T&gt;&gt;</code>, the other taking two parameters returning <code>failure_type&lt;std::decay_t&lt;T&gt;, std::decay_t&lt;U&gt;&gt;</code>. Both overloads perfectly forward their inputs.</p>
  16. <p>Note that <code>failure()</code> overloads are permitted by Outcome to return something other than <code>failure_type</code>. For example, <code>basic_result</code>&rsquo;s <a href="../../reference/types/basic_result/as_failure_lvalue.html" class="api-reference"><code>auto as_failure() const &amp;</code></a>
  17. returns whatever type <code>failure()</code> returns, and <a href="../../reference/macros/try.html" class="api-reference"><code>BOOST_OUTCOME_TRY(var, expr)</code></a>
  18. by default returns for failure whatever <code>.as_failure()</code> returns. This can be useful to have <code>BOOST_OUTCOME_TRY(...}</code> propagate on failure something custom for some specific input <code>basic_result</code> or <code>basic_outcome</code>.</p>
  19. <p><em>Overridable</em>: By Argument Dependent Lookup (ADL).</p>
  20. <p><em>Requires</em>: Always available.</p>
  21. <p><em>Namespace</em>: <code>BOOST_OUTCOME_V2_NAMESPACE</code></p>
  22. <p><em>Header</em>: <code>&lt;boost/outcome/success_failure.hpp&gt;</code></p>
  23. </div><p><small>Last revised: February 01, 2019 at 23:42:52 UTC</small></p>
  24. <hr>
  25. <div class="spirit-nav">
  26. <a accesskey="p" href="../../reference/functions/policy/outcome_throw_as_system_error_with_payload_std_error_code.html"><img src="../../images/prev.png" alt="Prev"></a>
  27. <a accesskey="u" href="../../reference/functions.html"><img src="../../images/up.png" alt="Up"></a>
  28. <a accesskey="h" href="../../index.html"><img src="../../images/home.png" alt="Home"></a><a accesskey="n" href="../../reference/functions/success.html"><img src="../../images/next.png" alt="Next"></a></div></body>
  29. </html>