]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/libs/math/test/test_hyperexponential_dist.cpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / math / test / test_hyperexponential_dist.cpp
index f11c847e41e7d5c12c3b2e086606a23e9ae26f51..7a30e77de27771ea012ef9940645514bad32aad5 100644 (file)
@@ -20,6 +20,7 @@
 #include <cstddef>
 #include <iostream>
 #include <vector>
+#include <tuple>
 
 #define BOOST_MATH_HYPEREXP_CHECK_CLOSE_COLLECTIONS(T, actual, expected, tol) \
     do {                                                                      \
         }                                                                     \
     } while(false)
 
-#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
-typedef boost::mpl::list<float, double, long double, boost::math::concepts::real_concept> test_types;
+#if !defined(BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS) && !defined(BOOST_MATH_NO_REAL_CONCEPT_TESTS)
+using test_types = std::tuple<float, double, long double, boost::math::concepts::real_concept>;
+#elif !defined(BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS)
+using test_types = std::tuple<float, double, long double>;
 #else
-typedef boost::mpl::list<float, double> test_types;
+using test_types = std::tuple<float, double>;
 #endif
 
 template <typename RealT>
@@ -304,8 +307,8 @@ void f(T t)
 
 BOOST_AUTO_TEST_CASE(construct)
 {
-   boost::array<double, 3> da1 = { { 0.5, 1, 1.5 } };
-   boost::array<double, 3> da2 = { { 0.25, 0.5, 0.25 } };
+   std::array<double, 3> da1 = { { 0.5, 1, 1.5 } };
+   std::array<double, 3> da2 = { { 0.25, 0.5, 0.25 } };
    std::vector<double> v1(da1.begin(), da1.end());
    std::vector<double> v2(da2.begin(), da2.end());
 
@@ -374,9 +377,9 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(special_cases, RealT, test_types)
 BOOST_AUTO_TEST_CASE_TEMPLATE(error_cases, RealT, test_types)
 {
    typedef boost::math::hyperexponential_distribution<RealT> dist_t;
-   boost::array<RealT, 2> probs = { { 1, 2 } };
-   boost::array<RealT, 3> probs2 = { { 1, 2, 3 } };
-   boost::array<RealT, 3> rates = { { 1, 2, 3 } };
+   std::array<RealT, 2> probs = { { 1, 2 } };
+   std::array<RealT, 3> probs2 = { { 1, 2, 3 } };
+   std::array<RealT, 3> rates = { { 1, 2, 3 } };
    BOOST_MATH_CHECK_THROW(dist_t(probs.begin(), probs.end(), rates.begin(), rates.end()), std::domain_error);
    BOOST_MATH_CHECK_THROW(dist_t(probs, rates), std::domain_error);
    rates[1] = 0;
@@ -385,4 +388,22 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(error_cases, RealT, test_types)
    BOOST_MATH_CHECK_THROW(dist_t(probs2, rates), std::domain_error);
    BOOST_MATH_CHECK_THROW(dist_t(probs.begin(), probs.begin(), rates.begin(), rates.begin()), std::domain_error);
    BOOST_MATH_CHECK_THROW(dist_t(rates.begin(), rates.begin()), std::domain_error);
+
+   // Test C++20 ranges (Currently only GCC10 has full support to P0896R4)
+   #if (__cplusplus > 202000L || _MSVC_LANG > 202000L) && __has_include(<ranges>) && __GNUC__ >= 10
+   // Support for ranges is broken using gcc 11.1
+   #if __GNUC__ != 11
+   #include <ranges>
+   #include <array>
+
+   std::array<RealT, 2> probs_array {1,2};
+   std::array<RealT, 3> rates_array {1,2,3};
+   BOOST_MATH_CHECK_THROW(dist_t(std::ranges::begin(probs_array), std::ranges::end(probs_array), std::ranges::begin(rates_array), std::ranges::end(rates_array)), std::domain_error);
+
+   const auto probs_range = probs_array | std::ranges::views::all;
+   const auto rates_range = rates_array | std::ranges::views::all;
+
+   BOOST_MATH_CHECK_THROW(dist_t(probs_range, rates_range), std::domain_error);
+   #endif
+   #endif
 }