Files
safe_numerics/doc/boostbook/throw_exception.xml
Robert Ramey 1bc0b94e65 changes to implement the following:
a) made trap_exception work
b) updated manual and examples to show how to use library to eliminate runtime penalty
c) added in safe_literal
d) made corrections of various types
2015-12-21 23:14:06 -08:00

49 lines
1.5 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.throw_exception">
<title>throw_exception</title>
<section id="safenumerics.throw_exception">
<title>Description</title>
<para>This exception policy throws a an exception derived from
<code>std::exception</code> any time some operation would result in an
incorrect result. This is the default exception handling policy.</para>
</section>
<section>
<title>Model of</title>
<para><link
linkend="safe_numerics.promotion_policy">ExceptionPolicy</link></para>
</section>
<section>
<title>Header</title>
<para><code><ulink url="../../include/exception_policy.hpp"><code>#include
&lt;boost/safe_numerics/exception_policies.hpp&gt;
</code></ulink></code></para>
</section>
<section>
<title>Example of use</title>
<para>This example is somewhat contrived as throw_exception is the default
for safe types. Hence it usually is not necessarily to request it
explicitly.</para>
<programlisting>#include "../../include/safe_integer.hpp"
#include "../../include/exception_policies" // exception policies
#include "../../include/native" // native promotion policy
int main(){
using namespace boost::numeric;
safe&lt;int, native, throw_exception&gt; i;
int j = 0;
i /= j; // throws exception
}</programlisting>
</section>
</section>