mirror of
https://github.com/boostorg/safe_numerics.git
synced 2026-02-22 15:42:30 +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
50 lines
1.5 KiB
XML
50 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.trap_exception">
|
|
<title>trap_exception</title>
|
|
|
|
<section>
|
|
<title>Description</title>
|
|
|
|
<para>This exception policy will trap at compile time any operation
|
|
<emphasis><emphasis role="bold">COULD</emphasis></emphasis> result in a
|
|
runtime exception. It can be used in an environment which can tolerate
|
|
neither arithmetic errors nor runtime overhead. Usage of this policy will
|
|
almost always require altering one's program to avoid exceptions.</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_policy.hpp>
|
|
</code></ulink></code></para>
|
|
</section>
|
|
|
|
<section>
|
|
<title>Example of use</title>
|
|
|
|
<para>The following</para>
|
|
|
|
<programlisting>#include "../../include/safe_integer.hpp"
|
|
#include "../../include/automatic.hpp"
|
|
#include "../../include/exception_policies.hpp"
|
|
|
|
int main(){
|
|
using namespace boost::numeric;
|
|
safe<char, automatic, trap_exception> x, y;
|
|
y = x * x; // compile error here !!!
|
|
auto z = x * x; // compile OK
|
|
return 0;
|
|
}</programlisting>
|
|
</section>
|
|
</section>
|