mirror of
https://github.com/boostorg/safe_numerics.git
synced 2026-02-22 03:32:24 +00:00
improved TOC and chunking. This is complicated by the fact we that we desire different depths. put copies of boost logo in subdirectories
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.exception_policies.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>
|