]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/libs/multiprecision/example/numeric_limits_snips.cpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / multiprecision / example / numeric_limits_snips.cpp
index 25e07d02d51bc98d1b8ab9a41d14d278085cb64c..4f4d06cad443c510d1d7ac7d4b795053f8e51fdb 100644 (file)
@@ -37,7 +37,7 @@
 // static long double const log10Two = 0.30102999566398119521373889472449L; // log10(2.)
 // It is more portable useful to use a Boost macro
 // See https://www.boost.org/doc/libs/release/libs/config/doc/html/boost_config/boost_macro_reference.html
-BOOST_STATIC_CONSTEXPR long double log10Two = 0.30102999566398119521373889472449L;
+static constexpr long double log10Two = 0.30102999566398119521373889472449L;
 // which expands to static constexpr on standard C++11 and up, but static const on earlier versions.
 
   /*`By default, output would only show the standard 6 decimal digits,
@@ -52,12 +52,11 @@ template <typename T>
 int max_digits10()
 {
    int significand_digits = std::numeric_limits<T>::digits;
-  // BOOST_CONSTEXPR_OR_CONST int significand_digits = std::numeric_limits<T>::digits;
+  // constexpr int significand_digits = std::numeric_limits<T>::digits;
    return static_cast<int>(ceil(1 + significand_digits * log10Two));
 } // template <typename T> int max_digits10()
 
 // Used to test max_digits10<>() function below.
-//#define BOOST_NO_CXX11_NUMERIC_LIMITS
 
 BOOST_AUTO_TEST_CASE(test_numeric_limits_snips)
 {
@@ -74,21 +73,11 @@ BOOST_AUTO_TEST_CASE(test_numeric_limits_snips)
 
   typedef float T;
 
-#if defined BOOST_NO_CXX11_NUMERIC_LIMITS
-   // No max_digits10 implemented.
-    std::cout.precision(max_digits10<T>());
-#else
-  #if(_MSC_VER <= 1600)
-   //  The MSVC 2010 version had the wrong value for std::numeric_limits<float>::max_digits10.
-    std::cout.precision(max_digits10<T>());
-  #else // Use the C++11 max_digits10.
-     std::cout.precision(std::numeric_limits<T>::max_digits10);
-     std::cout.precision(std::numeric_limits<T>::digits10);
-     std::cout.setf(std::ios_base::showpoint); // Append any trailing zeros,
-     // or more memorably
-     std::cout << std::showpoint << std::endl; //
-  #endif
-#endif
+  std::cout.precision(std::numeric_limits<T>::max_digits10);
+  std::cout.precision(std::numeric_limits<T>::digits10);
+  std::cout.setf(std::ios_base::showpoint); // Append any trailing zeros,
+  // or more memorably
+  std::cout << std::showpoint << std::endl; //
 
   std::cout << "std::cout.precision(max_digits10) = " << std::cout.precision() << std::endl; // 9
 
@@ -174,7 +163,7 @@ BOOST_AUTO_TEST_CASE(test_numeric_limits_snips)
   typedef double T;
 
   bool denorm = std::numeric_limits<T>::denorm_min() < (std::numeric_limits<T>::min)();
-  BOOST_ASSERT(denorm);
+  BOOST_MP_ASSERT(denorm);
 
 //] [/max_digits10_6]
   }
@@ -443,10 +432,10 @@ Then we can equally well use a multiprecision type cpp_bin_float_quad:
     ss.imbue(new_locale);
     T inf = std::numeric_limits<T>::infinity();
     ss << inf; // Write out.
-   BOOST_ASSERT(ss.str() == "inf");
+   BOOST_MP_ASSERT(ss.str() == "inf");
     T r;
     ss >> r; // Read back in.
-    BOOST_ASSERT(inf == r); // Confirms that the floating-point values really are identical.
+    BOOST_MP_ASSERT(inf == r); // Confirms that the floating-point values really are identical.
     std::cout << "infinity output was " << ss.str() << std::endl;
     std::cout << "infinity input was " << r << std::endl;
   }
@@ -467,7 +456,7 @@ Similarly we can do the same with NaN (except that we cannot use `assert` (becau
     T n;
     T NaN = std::numeric_limits<T>::quiet_NaN();
     ss << NaN; // Write out.
-    BOOST_ASSERT(ss.str() == "nan");
+    BOOST_MP_ASSERT(ss.str() == "nan");
     std::cout << "NaN output was " << ss.str() << std::endl;
     ss >> n; // Read back in.
     std::cout << "NaN input was " << n << std::endl;