]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/libs/algorithm/test/sort_subrange_test.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / algorithm / test / sort_subrange_test.cpp
index 4c1192eb8f56477ae1ca3182bcf0684eb6dcaeb4..de6a3fa46a9421eb9e323cfe0f6ca9e5d295bd6f 100644 (file)
@@ -7,6 +7,20 @@
 
 #include <vector>
 #include <iostream>
+
+#if __cplusplus >= 201103L
+#include <random>
+
+std::default_random_engine gen;
+template<typename RandomIt>
+void do_shuffle(RandomIt first, RandomIt last)
+{ std::shuffle(first, last, gen); }
+#else
+template<typename RandomIt>
+void do_shuffle(RandomIt first, RandomIt last)
+{ std::random_shuffle(first, last); }
+#endif
+
 namespace ba = boost::algorithm;
 
 template <typename Iter>
@@ -53,14 +67,14 @@ BOOST_AUTO_TEST_CASE( test_main )
        BOOST_CHECK_EQUAL(v[5], 5);
        
 //     Mix them up and try again - single element
-       std::random_shuffle(v.begin(), v.end());
+       do_shuffle(v.begin(), v.end());
        ba::sort_subrange(b, v.end(), b + 7, b + 8);
        check_sequence   (b, v.end(), b + 7, b + 8);
 
        BOOST_CHECK_EQUAL(v[7], 7);
 
 //     Mix them up and try again - at the end
-       std::random_shuffle(v.begin(), v.end());
+       do_shuffle(v.begin(), v.end());
        ba::sort_subrange(b, v.end(), b + 7, v.end());
        check_sequence   (b, v.end(), b + 7, v.end());
 
@@ -69,7 +83,7 @@ BOOST_AUTO_TEST_CASE( test_main )
        BOOST_CHECK_EQUAL(v[9], 9);
 
 //     Mix them up and try again - at the beginning
-       std::random_shuffle(v.begin(), v.end());
+       do_shuffle(v.begin(), v.end());
        ba::sort_subrange(b, v.end(), b, b + 2);
        check_sequence   (b, v.end(), b, b + 2);
 
@@ -77,12 +91,12 @@ BOOST_AUTO_TEST_CASE( test_main )
        BOOST_CHECK_EQUAL(v[1], 1);
 
 //     Mix them up and try again - empty subrange
-       std::random_shuffle(v.begin(), v.end());
+       do_shuffle(v.begin(), v.end());
        ba::sort_subrange(b, v.end(), b, b);
        check_sequence   (b, v.end(), b, b);
 
 //     Mix them up and try again - entire subrange
-       std::random_shuffle(v.begin(), v.end());
+       do_shuffle(v.begin(), v.end());
        ba::sort_subrange(b, v.end(), b, v.end());
        check_sequence   (b, v.end(), b, v.end());
        }
@@ -101,14 +115,14 @@ BOOST_AUTO_TEST_CASE( test_main )
        BOOST_CHECK_EQUAL(v[5], 4);
 
 //     Mix them up and try again - single element
-       std::random_shuffle(v.begin(), v.end());
+       do_shuffle(v.begin(), v.end());
        ba::sort_subrange(b, v.end(), b + 7, b + 8, std::greater<int>());
        check_sequence   (b, v.end(), b + 7, b + 8, std::greater<int>());
 
        BOOST_CHECK_EQUAL(v[7], 2);
 
 //     Mix them up and try again - at the end
-       std::random_shuffle(v.begin(), v.end());
+       do_shuffle(v.begin(), v.end());
        ba::sort_subrange(b, v.end(), b + 7, v.end(), std::greater<int>());
        check_sequence   (b, v.end(), b + 7, v.end(), std::greater<int>());
 
@@ -117,7 +131,7 @@ BOOST_AUTO_TEST_CASE( test_main )
        BOOST_CHECK_EQUAL(v[9], 0);
 
 //     Mix them up and try again - at the beginning
-       std::random_shuffle(v.begin(), v.end());
+       do_shuffle(v.begin(), v.end());
        ba::sort_subrange(b, v.end(), b, b + 2, std::greater<int>());
        check_sequence   (b, v.end(), b, b + 2, std::greater<int>());
 
@@ -125,12 +139,12 @@ BOOST_AUTO_TEST_CASE( test_main )
        BOOST_CHECK_EQUAL(v[1], 8);
 
 //     Mix them up and try again - empty subrange
-       std::random_shuffle(v.begin(), v.end());
+       do_shuffle(v.begin(), v.end());
        ba::sort_subrange(b, v.end(), b, b, std::greater<int>());
        check_sequence   (b, v.end(), b, b, std::greater<int>());
 
 //     Mix them up and try again - entire subrange
-       std::random_shuffle(v.begin(), v.end());
+       do_shuffle(v.begin(), v.end());
        ba::sort_subrange(b, v.end(), b, v.end(), std::greater<int>());
        check_sequence   (b, v.end(), b, v.end(), std::greater<int>());
        }