Commit 1962ee07 authored by Christopher Dykes's avatar Christopher Dykes Committed by Facebook Github Bot 7

Use a defined form of uniform_int_distribution

Summary: As per http://en.cppreference.com/w/cpp/numeric/random/uniform_int_distribution the behavior of using `uint8_t` as the template parameter is undefined, and is not supported on MSVC, so use `unsigned short` instead, which is a defined form.

Reviewed By: yfeldblum

Differential Revision: D3507309

fbshipit-source-id: c4c830371d08aee4a3de90bb394d22d92ad9a575
parent b292dfea
......@@ -43,7 +43,7 @@ void initialize() {
// word length = uniformly distributed between 1 and 10
// charset = 0x20 - 0x7f
std::uniform_int_distribution<size_t> term_len(1, 10);
std::uniform_int_distribution<uint8_t> term_char(0x20, 0x7f);
std::uniform_int_distribution<uint16_t> term_char(0x20, 0x7f);
for (int i = 0; i < kMaxTerms; i++) {
std::string& term = terms[i];
int len = term_len(rng);
......
......@@ -34,7 +34,7 @@ namespace detail {
std::vector<uint8_t> randomBytes(size_t n) {
std::vector<uint8_t> ret(n);
std::default_random_engine rng(1729); // Deterministic seed.
std::uniform_int_distribution<uint8_t> dist(0, 255);
std::uniform_int_distribution<uint16_t> dist(0, 255);
std::generate(ret.begin(), ret.end(), [&] () { return dist(rng); });
return ret;
}
......
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