Files
safe_numerics/doc/html/safe.html
2013-11-04 11:44:56 -08:00

156 lines
6.6 KiB
HTML

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>safe&lt;T&gt;</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="types.html" title="Types">
<link rel="prev" href="safe_signed_range.html" title="safe_signed_range&lt;MIN, MAX&gt;">
<link rel="next" href="functions.html" title="Functions">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="pre-boost" width="30%" height="30%" src="pre-boost.jpg"></td>
<td align="center"><a href="../../index.html">Home</a></td>
<td align="center"><a href="http://www.boost.org/doc/libs">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="safe_signed_range.html"><img src="images/prev.png" alt="Prev"></a><a accesskey="u" href="types.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="functions.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.safe"></a>safe&lt;T&gt;</h3></div></div></div>
<div class="toc"><dl>
<dt><span class="section"><a href="safe.html#id753980">Description</a></span></dt>
<dt><span class="section"><a href="safe.html#id753999">Template Parameters</a></span></dt>
<dt><span class="section"><a href="safe.html#id754085">Model of</a></span></dt>
<dt><span class="section"><a href="safe.html#id754099">Derived From</a></span></dt>
<dt><span class="section"><a href="safe.html#id754139">Notation</a></span></dt>
<dt><span class="section"><a href="safe.html#id754225">Header</a></span></dt>
<dt><span class="section"><a href="safe.html#id754246">Example of use</a></span></dt>
<dt><span class="section"><a href="safe.html#id754272">Notes</a></span></dt>
<dt><span class="section"><a href="safe.html#id754284">See Also</a></span></dt>
</dl></div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="id753980"></a>Description</h4></div></div></div>
<p>A <code class="computeroutput">safe&lt;T&gt;</code> can be used anywhere a type T is used.
When T is used in operation which overflows, a exception is thrown</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="id753999"></a>Template Parameters</h4></div></div></div>
<p></p>
<div class="informaltable"><table class="table">
<colgroup>
<col align="left">
<col align="left">
<col align="left">
</colgroup>
<thead><tr>
<th align="left">Parameter</th>
<th align="left">Type Requirements</th>
<th align="left">Description</th>
</tr></thead>
<tbody><tr>
<td align="left"><code class="computeroutput">T</code></td>
<td align="left"><a class="link" href="numeric.html" title="Numeric&lt;T&gt;">Numeric</a></td>
<td align="left"><p>The underlying integer type</p></td>
</tr></tbody>
</table></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="id754085"></a>Model of</h4></div></div></div>
<p><a class="link" href="numeric.html" title="Numeric&lt;T&gt;">Numeric</a></p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="id754099"></a>Derived From</h4></div></div></div>
<p><code class="computeroutput"><a class="link" href="safe_signed_range.html" title="safe_signed_range&lt;MIN, MAX&gt;">safe_signed_range&lt;T&gt;</a></code>
(if std::numeric_limits&lt;T&gt;::is_signed == ftrue)</p>
<p><code class="computeroutput"><a class="link" href="safe_unsigned_range.html" title="safe_unsigned_range&lt;MIN, MAX&gt;">safe_unsigned_range&lt;T&gt;</a></code>
(if std::numeric_limits&lt;T&gt;::is_signed == ftrue)</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="id754139"></a>Notation</h4></div></div></div>
<div class="informaltable"><table class="table">
<colgroup>
<col align="left">
<col align="left">
</colgroup>
<thead><tr>
<th align="left">Symbol</th>
<th align="left">Description</th>
</tr></thead>
<tbody>
<tr>
<td align="left"><code class="computeroutput">T</code></td>
<td align="left">A type that models the <a class="link" href="numeric.html" title="Numeric&lt;T&gt;">Numeric</a> concept</td>
</tr>
<tr>
<td align="left">t</td>
<td align="left">An object of type <code class="computeroutput">T</code>
</td>
</tr>
</tbody>
</table></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="id754225"></a>Header</h4></div></div></div>
<p><code class="filename"><a href="../../include/safe_integer.hpp" target="_top">#include
&lt;boost/safe_numerics/safe_integer.hpp&gt;</a></code></p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="id754246"></a>Example of use</h4></div></div></div>
<p>The following program will emit an error message on a machine where
int is only 16 bits but run without problem on a machine where int is 32
bits.</p>
<pre class="programlisting">#include &lt;boost/numeric/safe.hpp&gt;
#include &lt;iostream&gt;
void f(){
safe&lt;int&gt; i = 400;
safe&lt;int&gt; j;
try {
j = i * i;
}
catch(...){
std::cout &lt;&lt; "overflow error" &lt;&lt; std::endl;
}
}
</pre>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="id754272"></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="id754284"></a>See Also</h4></div></div></div>
<p>Footnotes (if any) that are referred to by other parts of the
page.</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="???" target="_top">Subject to Boost Software License</a></p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="safe_signed_range.html"><img src="images/prev.png" alt="Prev"></a><a accesskey="u" href="types.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="functions.html"><img src="images/next.png" alt="Next"></a>
</div>
</body>
</html>