mirror of
https://github.com/boostorg/safe_numerics.git
synced 2026-02-03 09:22:19 +00:00
19 lines
460 B
C++
19 lines
460 B
C++
#include <iostream>
|
|
|
|
#include "../include/safe_integer.hpp"
|
|
#include "../include/exception.hpp" // include exception policies
|
|
|
|
using safe_t = boost::numeric::safe<
|
|
int,
|
|
boost::numeric::native,
|
|
boost::numeric::trap_exception // note use of "trap_exception" policy!
|
|
>;
|
|
|
|
int main(int argc, const char * argv[]){
|
|
std::cout << "example 81:\n";
|
|
safe_t x(INT_MAX);
|
|
safe_t y(2);
|
|
safe_t z = x + y; // will fail to compile !
|
|
return 0;
|
|
}
|