| 1 | // Copyright (c) 2018 Robert Ramey |
|---|---|
| 2 | // |
| 3 | // Distributed under the Boost Software License, Version 1.0. (See |
| 4 | // accompanying file LICENSE_1_0.txt or copy at |
| 5 | // http://www.boost.org/LICENSE_1_0.txt) |
| 6 | |
| 7 | #include <iostream> |
| 8 | |
| 9 | #include <boost/safe_numerics/safe_integer.hpp> |
| 10 | #include <boost/safe_numerics/exception_policies.hpp> // include exception policies |
| 11 | |
| 12 | using safe_t = boost::safe_numerics::safe< |
| 13 | int, |
| 14 | boost::safe_numerics::native, |
| 15 | boost::safe_numerics::loose_trap_policy // note use of "loose_trap_exception" policy! |
| 16 | >; |
| 17 | |
| 18 | int main(){ |
| 19 | std::cout << "example 81:\n"; |
| 20 | safe_t x(INT_MAX); |
| 21 | safe_t y(2); |
| 22 | safe_t z = x + y; // will fail to compile ! |
| 23 | return 0; |
| 24 | } |
| 25 |
