swap.html 3.4 KB

12345678910111213141516171819202122232425262728293031
  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>void swap(basic_outcome &amp;) - 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/inequality_failure_type.html"><img src="../../../images/prev.png" alt="Prev"></a>
  10. <a accesskey="u" href="../../../reference/types/basic_outcome.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_outcome/as_failure_lvalue.html"><img src="../../../images/next.png" alt="Next"></a></div><div id="content">
  12. <div class="titlepage"><div><div><h1 style="clear: both"><code>void swap(basic_outcome &amp;)</code></h1></div></div></div>
  13. <p>Swap one basic_outcome with another, with the strong guarantee. Constexpr if move constructors and move assignments of <code>value_type</code>, <code>error_type</code> and <code>exception_type</code> are noexcept.</p>
  14. <p><em>Requires</em>: Always available.</p>
  15. <p><em>Complexity</em>: If the move constructor and move assignment for <code>value_type</code>, <code>error_type</code> and <code>exception_type</code> are noexcept, the complexity is the same as for the <code>swap()</code> implementations of the <code>value_type</code>, <code>error_type</code> and <code>exception_type</code>. Otherwise, complexity is not preserved, as <a href="../../../reference/functions/strong_swap.html" class="api-reference"><code>strong_swap(bool &amp;all_good, T &amp;a, T &amp;b)</code></a>
  16. is used instead of <code>swap()</code>. This function defaults to using one move construction and two assignments, and it will attempt extra move assignments in order to restore the state upon entry if a failure occurs.</p>
  17. <p><em>Guarantees</em>: If an exception is thrown during the swap operation, the state of all three operands on entry is attempted to be restored, in order to implement the strong guarantee. If that too fails, the flag bits are forced to something consistent such that there can be no simultaneously valued and errored/excepted state, or valueless and errorless/exceptionless. The flag <a href="../../../reference/types/basic_result/has_lost_consistency.html" class="api-reference"><code>has_lost_consistency()</code></a>
  18. becomes true for both operands, which are now likely in an inconsistent state.</p>
  19. </div><p><small>Last revised: June 25, 2019 at 17:01:21 &#43;0100</small></p>
  20. <hr>
  21. <div class="spirit-nav">
  22. <a accesskey="p" href="../../../reference/types/basic_outcome/inequality_failure_type.html"><img src="../../../images/prev.png" alt="Prev"></a>
  23. <a accesskey="u" href="../../../reference/types/basic_outcome.html"><img src="../../../images/up.png" alt="Up"></a>
  24. <a accesskey="h" href="../../../index.html"><img src="../../../images/home.png" alt="Home"></a><a accesskey="n" href="../../../reference/types/basic_outcome/as_failure_lvalue.html"><img src="../../../images/next.png" alt="Next"></a></div></body>
  25. </html>