advantages.html 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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>The main advantages - 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="../experimental.html"><img src="../images/prev.png" alt="Prev"></a>
  10. <a accesskey="u" href="../experimental.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="../experimental/map.html"><img src="../images/next.png" alt="Next"></a></div><div id="content">
  12. <div class="titlepage"><div><div><h1 style="clear: both">The main advantages</h1></div></div></div>
  13. <p>The main advantages of choosing <code>&lt;boost/outcome/experimental&gt;</code> over default Outcome:</p>
  14. <ol>
  15. <li><p>Codegen is tighter and less verbose<sup class="footnote-ref" id="fnref:1"><a href="#fn:1">1</a></sup>, sometimes remarkably so.</p></li>
  16. <li><p>Build time impact is markedly lower, barely above the inclusion of naked
  17. <code>&lt;basic_result.hpp&gt;</code>, as the STL allocator machinery and <code>std::string</code> et al
  18. is not dragged into inclusion by including <code>&lt;system_error&gt;</code>. Note that
  19. <code>&lt;boost/outcome/experimental/status_outcome.hpp&gt;</code> bring in <code>&lt;exception&gt;</code>,
  20. however <code>&lt;boost/outcome/experimental/status_result.hpp&gt;</code> brings in no extra system
  21. headers.</p></li>
  22. <li><p>More discipline is imposed on your use of Outcome, leading to
  23. less ambiguous code which is easier to optimise by the compiler,
  24. lower cost to maintain, and lower cognitive load to audit code based on
  25. experimental Outcome for correctness.</p></li>
  26. <li><p>Code written to <code>&lt;boost/outcome/experimental&gt;</code> can be fairly easily dual
  27. targeted, with just a few switching type aliases, to default Outcome.
  28. This author has several Outcome-based libraries with identical source code which
  29. can target either configuration of Outcome. The experimental Outcome
  30. build regularly beats the default Outcome build in benchmarks by 2-3%,
  31. and the dual target source code, being written to tighter discipline,
  32. is faster and more deterministic in the default target than it was before
  33. the (non-trivial) port to <code>&lt;boost/outcome/experimental&gt;</code>.</p></li>
  34. </ol>
  35. <p>If you are building a codebase on top of Outcome expecting long term
  36. maintenance, the author&rsquo;s personal recommendation is that you design, write, test and
  37. optimise it for <code>&lt;boost/outcome/experimental&gt;</code>. What you ship to your customers
  38. ought to be targeted at default Outcome however, so employ type aliases and
  39. macros as appropriate to switch the build configuration for production releases.
  40. This is what the Outcome author does himself, to date with great success,
  41. despite the fundamental architectural differences between <code>&lt;system_error&gt;</code>
  42. and proposed <code>&lt;system_error2&gt;</code>.</p>
  43. <div class="footnotes">
  44. <hr />
  45. <ol>
  46. <li id="fn:1">Boost.System&rsquo;s <code>error_code</code> has incorporated some of the design improvements of experimental <code>status_code</code>, and produces codegen somewhere in between experimental <code>status_code</code> and <code>std::error_code</code>.
  47. <a class="footnote-return" href="#fnref:1"><sup>[return]</sup></a></li>
  48. </ol>
  49. </div>
  50. </div><p><small>Last revised: February 05, 2019 at 21:41:47 UTC</small></p>
  51. <hr>
  52. <div class="spirit-nav">
  53. <a accesskey="p" href="../experimental.html"><img src="../images/prev.png" alt="Prev"></a>
  54. <a accesskey="u" href="../experimental.html"><img src="../images/up.png" alt="Up"></a>
  55. <a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="../experimental/map.html"><img src="../images/next.png" alt="Next"></a></div></body>
  56. </html>