Files
safe_numerics/doc/html/checked_integer_arithmetic.html
2015-12-21 23:17:05 -08:00

150 lines
6.8 KiB
HTML

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Checked Integer Arithmetic</title>
<link rel="stylesheet" href="boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
<link rel="home" href="index.html" title="Safe Numerics">
<link rel="up" href="library_implementation.html" title="Library Implementation">
<link rel="prev" href="checked_result.html" title="checked_result&lt;typename R&gt;">
<link rel="next" href="interval.html" title="interval&lt;typename R&gt;">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img href="index.html" height="164px" src="pre-boost.jpg" alt="Library Documentation Index"></td>
<td><h2>Safe Numerics</h2></td>
</tr></table>
<div class="spirit-nav">
<a accesskey="p" href="checked_result.html"><img src="images/prev.png" alt="Prev"></a><a accesskey="u" href="library_implementation.html"><img src="images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="images/home.png" alt="Home"></a><a accesskey="n" href="interval.html"><img src="images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="safe_numerics.checked_integer_arithmetic"></a>Checked Integer Arithmetic</h3></div></div></div>
<div class="toc"><dl>
<dt><span class="section"><a href="checked_integer_arithmetic.html#idm473861327744">Synopsis</a></span></dt>
<dt><span class="section"><a href="checked_integer_arithmetic.html#idm473861326032">Description</a></span></dt>
<dt><span class="section"><a href="checked_integer_arithmetic.html#idm473861324592">Type requirements</a></span></dt>
<dt><span class="section"><a href="checked_integer_arithmetic.html#idm473861322720">Complexity</a></span></dt>
<dt><span class="section"><a href="checked_integer_arithmetic.html#idm473861321568">Header</a></span></dt>
<dt><span class="section"><a href="checked_integer_arithmetic.html#idm473861319936">Example of use</a></span></dt>
<dt><span class="section"><a href="checked_integer_arithmetic.html#idm473861317680">Notes</a></span></dt>
<dt><span class="section"><a href="checked_integer_arithmetic.html#idm473861316528">See Also</a></span></dt>
</dl></div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="idm473861327744"></a>Synopsis</h4></div></div></div>
<pre class="programlisting">// safe casting on primitive types
template&lt;class R, class T&gt;
constexpr checked_result&lt;R&gt;
checked::cast(const T &amp; t);
// safe addition on primitive types
template&lt;class R, class T, class U&gt;
constexpr checked_result&lt;R&gt;
checked::add(const T &amp; t, const U &amp; u);
// safe subtraction on primitive types
template&lt;class R, class T, class U&gt;
constexpr checked_result&lt;R&gt;
checked::subtract(const T &amp; t, const U &amp; u);
// safe multiplication on primitive types
template&lt;class R, class T, class U&gt;
constexpr checked_result&lt;R&gt;
checked::multiply(const T &amp; t, const U &amp; u);
// safe division on unsafe types
template&lt;class R, class T, class U&gt;
constexpr checked_result&lt;R&gt;
checked::divide(const T &amp; t, const U &amp; u);
template&lt;class R, class T, class U&gt;
constexpr checked_result&lt;R&gt;
checked::divide_automatic(const T &amp; t, const U &amp; u);
// safe modulus on unsafe types
template&lt;class R, class T, class U&gt;
constexpr checked_result&lt;R&gt;
checked::modulus(const T &amp; t, const U &amp; u);
// left shift
template&lt;class R, class T, class U&gt;
constexpr checked_result&lt;R&gt;
checked::left_shift(const T &amp; t, const U &amp; u);
// right shift
template&lt;class R, class T, class U&gt;
constexpr checked_result&lt;R&gt;
checked::right_shift(const T &amp; t, const U &amp; u);
// bitwise operations
template&lt;class R, class T, class U&gt;
constexpr checked_result&lt;R&gt;
checked::bitwise_or(const T &amp; t, const U &amp; u);
template&lt;class R, class T, class U&gt;
constexpr checked_result&lt;R&gt;
checked::bitwise_and(const T &amp; t, const U &amp; u);
template&lt;class R, class T, class U&gt;
constexpr checked_result&lt;R&gt;
checked::bitwise_xor(const T &amp; t, const U &amp; u);
</pre>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="idm473861326032"></a>Description</h4></div></div></div>
<p>Perform binary operations on arithmetic types. Return either a valid
result or an error code. Under no circumstances should an incorrect result
be returned.</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="idm473861324592"></a>Type requirements</h4></div></div></div>
<p>All template parameters of the functions must model <a class="link" href="integer.html" title="Integer&lt;T&gt;">Integer</a> type requirements.</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="idm473861322720"></a>Complexity</h4></div></div></div>
<p>Each function performs one and only one arithmetic operation</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="idm473861321568"></a>Header</h4></div></div></div>
<p><code class="computeroutput">#include "checked.hpp" </code></p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="idm473861319936"></a>Example of use</h4></div></div></div>
<p>[A code fragment that illustrates how to use the function.]</p>
<pre class="programlisting">#include "checked.hpp"
checked_result&lt;result_base_type&gt; r = checked::multiply&lt;int&gt;(24, 42);
</pre>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="idm473861317680"></a>Notes</h4></div></div></div>
<p>Footnotes (if any) that are referred to by other parts of the
page.</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="idm473861316528"></a>See Also</h4></div></div></div>
<p><a class="link" href="checked_result.html" title="checked_result&lt;typename R&gt;">checked_result&lt;typename
R&gt;</a></p>
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2012 Robert Ramey<p><a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">Subject to Boost
Software License</a></p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="checked_result.html"><img src="images/prev.png" alt="Prev"></a><a accesskey="u" href="library_implementation.html"><img src="images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="images/home.png" alt="Home"></a><a accesskey="n" href="interval.html"><img src="images/next.png" alt="Next"></a>
</div>
</body>
</html>