From 5c6e19f0001e29915be2e7cd08731e00f4007ca5 Mon Sep 17 00:00:00 2001 From: Mark Mentovai Date: Wed, 15 Aug 2018 13:27:22 -0400 Subject: [PATCH] Use std::shuffle instead of std::random_shuffle MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit mcgrathr points out in https://chromium-review.googlesource.com/1172090 that std::random_shuffle is deprecated in C++14 and removed in C++17. Rather than having mini_chromium mimic Chromium’s base by providing RandomShuffle (Chromium 5de2157f1e7f), just use the standard library’s std::shuffle with mt19937(random_generator). Change-Id: I8c2b3101bf324350351dba9edda1ba230b1c6710 Reviewed-on: https://chromium-review.googlesource.com/1176122 Reviewed-by: Robert Sesek Commit-Queue: Mark Mentovai --- client/prune_crash_reports_test.cc | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/client/prune_crash_reports_test.cc b/client/prune_crash_reports_test.cc index 01990d27..9f5852e6 100644 --- a/client/prune_crash_reports_test.cc +++ b/client/prune_crash_reports_test.cc @@ -18,11 +18,11 @@ #include #include +#include #include #include #include "base/numerics/safe_conversions.h" -#include "base/rand_util.h" #include "gmock/gmock.h" #include "gtest/gtest.h" #include "test/scoped_temp_dir.h" @@ -218,11 +218,8 @@ TEST(PruneCrashReports, PruneOrder) { temp.creation_time = NDaysAgo(i * 10); reports.push_back(temp); } - // The randomness from std::rand() is not, so use a better rand() instead. - const auto random_generator = [](ptrdiff_t rand_max) { - return base::RandInt(0, base::checked_cast(rand_max) - 1); - }; - std::random_shuffle(reports.begin(), reports.end(), random_generator); + std::mt19937 urng(std::random_device{}()); + std::shuffle(reports.begin(), reports.end(), urng); std::vector pending_reports( reports.begin(), reports.begin() + 5); std::vector completed_reports(