Skip to content

Commit

Permalink
Replace std::random_shuffle with std::shuffle
Browse files Browse the repository at this point in the history
According to [1], std::random_shuffle is deprecated in C++14 and removed
in C++17. Since std::shuffle is available since C++11 as a replacement
and monero already requires C++11, this is a good replacement.

[1]: https://en.cppreference.com/w/cpp/algorithm/random_shuffle
  • Loading branch information
tomsmeding committed Aug 13, 2019
1 parent 1bb4ae3 commit a8fa90a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/p2p/net_peerlist.h
Expand Up @@ -290,7 +290,7 @@ namespace nodetool

if (anonymize)
{
std::random_shuffle(bs_head.begin(), bs_head.end());
std::shuffle(bs_head.begin(), bs_head.end(), std::default_random_engine(crypto::rand<unsigned>()));
if (bs_head.size() > depth)
bs_head.resize(depth);
for (auto &e: bs_head)
Expand Down
4 changes: 2 additions & 2 deletions tests/unit_tests/ringct.cpp
Expand Up @@ -779,8 +779,8 @@ TEST(ringct, range_proofs_accept_very_long_simple)
inputs[n] = n;
outputs[n] = n;
}
std::random_shuffle(inputs, inputs + N);
std::random_shuffle(outputs, outputs + N);
std::shuffle(inputs, inputs + N, std::default_random_engine(crypto::rand<unsigned>()));
std::shuffle(outputs, outputs + N, std::default_random_engine(crypto::rand<unsigned>()));
EXPECT_TRUE(range_proof_test(true, NELTS(inputs), inputs, NELTS(outputs), outputs, false, true));
}

Expand Down

0 comments on commit a8fa90a

Please sign in to comment.