• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include <boost/safe_numerics/safe_integer.hpp>
2 #include <boost/safe_numerics/safe_integer_literal.hpp>
3 
4 using namespace boost::safe_numerics;
5 
f(int i)6 int f(int i){
7     return i;
8 }
9 
10 template<intmax_t N>
11 using safe_literal = safe_signed_literal<N, native, loose_trap_policy>;
12 
main()13 int main(){
14     const long x = 97;
15     f(x);   // OK - implicit conversion to int
16     const safe_literal<97> y;
17     f(y);   // OK - y is a type with min/max = 97;
18     return 0;
19 }