Files
safe_numerics/doc/boostbook/automatic.xml
Robert Ramey 63dd89210e Enabled Boost Book syntax highlighting
improved TOC and chunking.  This is complicated by the fact we that we desire different depths.
put copies of boost logo in subdirectories
2016-02-07 14:38:06 -08:00

52 lines
1.6 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE section PUBLIC "-//Boost//DTD BoostBook XML V1.1//EN"
"http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
<section id="safe_numerics.promotion_policies.automatic">
<title>automatic</title>
<section>
<title>Description</title>
<para>This type contains the functions to return a type with sufficient
capacity to hold the result of a given arithmetic operation.</para>
</section>
<section>
<title>Model of</title>
<para><link
linkend="safe_numerics.promotion_policy">PromotionPolicy</link></para>
</section>
<section>
<title>Header</title>
<para><code><ulink url="../../include/automatic.hpp"><code>#include
&lt;boost/safe_numerics/automatic.hpp&gt; </code></ulink></code></para>
</section>
<section>
<title>Example of use</title>
<para>The following example illustrates the <code>automatic</code> type
being passed as a template parameter for the type
<code>safe&lt;int&gt;</code>.</para>
<programlisting>#include &lt;boost/safe_numerics/safe_integer.hpp&gt;
#include &lt;boost/safe_numerics/automatic.hpp&gt;
int main(){
using namespace boost::numeric;
// use automatic promotion policy where C++ standard arithmetic might lead to incorrect results
using safe_t = safe&lt;std::int8_t, automatic&gt;;
// In such cases, there is no runtime overhead from using safe types.
safe_t x = 127;
safe_t y = 2;
auto z = x + y; // z is guarenteed correct without any runtime overhead or interrupt.
return 0;
}</programlisting>
</section>
</section>