Add assertion to randrange that input is not 0

This commit is contained in:
Jeremy Rubin 2019-10-28 16:42:39 -07:00
parent 4c1090c882
commit a35b6824f3

View File

@ -166,6 +166,7 @@ public:
/** Generate a random integer in the range [0..range). */ /** Generate a random integer in the range [0..range). */
uint64_t randrange(uint64_t range) noexcept uint64_t randrange(uint64_t range) noexcept
{ {
assert(range);
--range; --range;
int bits = CountBits(range); int bits = CountBits(range);
while (true) { while (true) {