From 46dd8b1e13678d38a678d34efb8dd2825477d121 Mon Sep 17 00:00:00 2001 From: zpalmtree <22151537+zpalmtree@users.noreply.github.com> Date: Thu, 11 Oct 2018 10:48:12 -0700 Subject: [PATCH] C++17 support (#4482) Summary: Closes https://github.com/facebook/rocksdb/issues/4462 I'm not sure if you'll be happy with `std::random_device{}`, perhaps you would want to use your rand instance instead. I didn't test to see if your rand instance supports the requirements that `std::shuffle` takes. Pull Request resolved: https://github.com/facebook/rocksdb/pull/4482 Differential Revision: D10325133 Pulled By: yiwu-arbug fbshipit-source-id: 47b7adaf4bb2b8d64cf090ea6b1b48ef53180581 --- util/transaction_test_util.cc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/util/transaction_test_util.cc b/util/transaction_test_util.cc index 633391891..58d95b2ae 100644 --- a/util/transaction_test_util.cc +++ b/util/transaction_test_util.cc @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -135,8 +136,7 @@ bool RandomTransactionInserter::DoInsert(DB* db, Transaction* txn, std::vector set_vec(num_sets_); std::iota(set_vec.begin(), set_vec.end(), static_cast(0)); - std::random_shuffle(set_vec.begin(), set_vec.end(), - [&](uint64_t r) { return rand_->Uniform(r); }); + std::shuffle(set_vec.begin(), set_vec.end(), std::random_device{}); // For each set, pick a key at random and increment it for (uint16_t set_i : set_vec) { @@ -258,10 +258,8 @@ Status RandomTransactionInserter::Verify(DB* db, uint16_t num_sets, std::vector set_vec(num_sets); std::iota(set_vec.begin(), set_vec.end(), static_cast(0)); - if (rand) { - std::random_shuffle(set_vec.begin(), set_vec.end(), - [&](uint64_t r) { return rand->Uniform(r); }); - } + std::shuffle(set_vec.begin(), set_vec.end(), std::random_device{}); + // For each set of keys with the same prefix, sum all the values for (uint16_t set_i : set_vec) { // Five digits (since the largest uint16_t is 65535) plus the NUL