]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/safe_numerics/example/example82.cpp
bump version to 18.2.4-pve3
[ceph.git] / ceph / src / boost / libs / safe_numerics / example / example82.cpp
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>
11 #include <boost/safe_numerics/automatic.hpp>
12 #include "safe_format.hpp" // prints out range and value of any type
13
14 using safe_t = boost::safe_numerics::safe<
15 int,
16 boost::safe_numerics::automatic, // note use of "automatic" policy!!!
17 boost::safe_numerics::loose_trap_policy
18 >;
19
20 int main(int, const char *[]){
21 std::cout << "example 82:\n";
22 safe_t x(INT_MAX);
23 safe_t y = 2;
24 std::cout << "x = " << safe_format(x) << std::endl;
25 std::cout << "y = " << safe_format(y) << std::endl;
26 std::cout << "x + y = " << safe_format(x + y) << std::endl;
27 return 0;
28 }
29