Commit dc13d4a3 authored by Joe Loser's avatar Joe Loser Committed by Facebook Github Bot

Replace std::random_shuffle with std::shuffle (#993)

Summary:
- `std::random_shuffle` is deprecated in C++14 and removed in C++17.
- While `Folly` only depends on C++14, it should not hinder users from
  building in C++17 mode.
- To support users building with C++17 where `std::random_shuffle` is
  removed from the standard library, migrate the one call site to use
  `std::shuffle`.
Pull Request resolved: https://github.com/facebook/folly/pull/993

Reviewed By: Orvid

Differential Revision: D13620930

Pulled By: yfeldblum

fbshipit-source-id: 630d1125155e022f4b3e804f92c02ec663a86c3b
parent b9967308
...@@ -52,7 +52,8 @@ class ArenaTester { ...@@ -52,7 +52,8 @@ class ArenaTester {
void ArenaTester::allocate(size_t count, size_t maxSize) { void ArenaTester::allocate(size_t count, size_t maxSize) {
// Allocate chunks of memory of random sizes // Allocate chunks of memory of random sizes
std::mt19937 rnd; std::random_device rd{};
std::mt19937 rnd{rd()};
std::uniform_int_distribution<uint32_t> sizeDist(1, maxSize - 1); std::uniform_int_distribution<uint32_t> sizeDist(1, maxSize - 1);
areas_.clear(); areas_.clear();
areas_.reserve(count); areas_.reserve(count);
...@@ -64,9 +65,7 @@ void ArenaTester::allocate(size_t count, size_t maxSize) { ...@@ -64,9 +65,7 @@ void ArenaTester::allocate(size_t count, size_t maxSize) {
// Fill each area with a different value, to prove that they don't overlap // Fill each area with a different value, to prove that they don't overlap
// Fill in random order. // Fill in random order.
std::random_shuffle(areas_.begin(), areas_.end(), [&rnd](ptrdiff_t n) { std::shuffle(areas_.begin(), areas_.end(), rnd);
return std::uniform_int_distribution<uint32_t>(0, n - 1)(rnd);
});
for (auto& p : areas_) { for (auto& p : areas_) {
std::fill(p.second.begin(), p.second.end(), p.first); std::fill(p.second.begin(), p.second.end(), p.first);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment