Replace std::random_shuffle (removed in C++17).
authorCarl Hetherington <cth@carlh.net>
Mon, 18 Mar 2024 20:05:07 +0000 (21:05 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 20 Mar 2024 17:25:09 +0000 (18:25 +0100)
test/image_filename_sorter_test.cc

index eb662a120e14da3c86f26b8330b0f3e57d44af92..29b550753e45c32c950ee0a336137391ab054107 100644 (file)
 #include "lib/image_filename_sorter.h"
 #include "lib/compose.hpp"
 #include <boost/test/unit_test.hpp>
+#include <algorithm>
+#include <random>
 
 
-using std::random_shuffle;
 using std::sort;
 using std::vector;
 
@@ -69,7 +70,11 @@ BOOST_AUTO_TEST_CASE (image_filename_sorter_test2)
        for (int i = 0; i < 100000; ++i) {
                paths.push_back(String::compose("some.filename.with.%1.number.tiff", i));
        }
-       random_shuffle (paths.begin(), paths.end());
+
+       std::random_device rd;
+       std::mt19937 generator(rd());
+       std::shuffle(paths.begin(), paths.end(), generator);
+
        sort (paths.begin(), paths.end(), ImageFilenameSorter());
        for (int i = 0; i < 100000; ++i) {
                BOOST_CHECK_EQUAL(paths[i].string(), String::compose("some.filename.with.%1.number.tiff", i));