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