]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/libs/safe_numerics/test/test_z.cpp
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / boost / libs / safe_numerics / test / test_z.cpp
index 795ed4f8c929284e876d54e7d1bc88ebc859d6a7..d7035c2930b943fa3c81120bce3c1a5642bf5245 100644 (file)
@@ -232,7 +232,7 @@ constexpr T base_value(const T & t){
     return t;
 }
 
-template<typename R, R Min, R Max, typename T, typename E>
+template<typename R, R Min, R Max, typename E>
 struct validate_detail {
 
     constexpr static const interval<checked_result<R>> t_interval{
@@ -729,7 +729,7 @@ int main(){
 
 #include <iostream>
 #include <boost/safe_numerics/safe_integer.hpp>
-#include <boost/safe_numerics/automatic.hpp>
+//#include <boost/safe_numerics/automatic.hpp>
 
 using namespace boost::safe_numerics;
 
@@ -753,6 +753,41 @@ int main(){
 
     return 0;
 }
+
+
+#include <cstdint>
+#include <boost/safe_numerics/safe_integer_range.hpp>
+#include <boost/safe_numerics/safe_integer_literal.hpp>
+
+template <uintmax_t Min, uintmax_t Max>
+using urange = boost::safe_numerics::safe_unsigned_range<
+    Min,
+    Max,
+    boost::safe_numerics::native,
+    boost::safe_numerics::strict_trap_policy
+>;
+
+template <uintmax_t N>
+using ulit = boost::safe_numerics::safe_unsigned_literal<
+    N,
+    boost::safe_numerics::native,
+    boost::safe_numerics::strict_trap_policy
+>;
+
+int main(){
+    urange<0,4095> x = ulit<0>(); // 12 bits
+    urange<0, 69615> y = x * ulit<17>(); // no error - resulting value
+        // cannot exceed  69615
+    auto z = y / ulit<17>() ; //Boom, compile-time error
+    return z;
+}
+
 #endif
 
-int main(){}
+#include <boost/safe_numerics/safe_integer_range.hpp>
+
+int main(){
+    using namespace boost::safe_numerics;
+    safe_unsigned_range<0, 36> a = 30;
+    return 0;
+}