mirror of
https://github.com/boostorg/safe_numerics.git
synced 2026-02-22 15:42:30 +00:00
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
49 lines
1.5 KiB
XML
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
|
|
<boost/safe_numerics/exception_policies.hpp>
|
|
</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<int, native, throw_exception> i;
|
|
int j = 0;
|
|
i /= j; // throws exception
|
|
}</programlisting>
|
|
</section>
|
|
</section>
|