I need a function which would generate a random integer in given range (including border values). I don\'t unreasonable quality/randomness requirements, I have four requirem
The simplest (and hence best) C++ (using the 2011 standard) answer is
#include
std::random_device rd; // only used once to initialise (seed) engine
std::mt19937 rng(rd()); // random-number engine used (Mersenne-Twister in this case)
std::uniform_int_distribution uni(min,max); // guaranteed unbiased
auto random_integer = uni(rng);
No need to re-invent the wheel. No need to worry about bias. No need to worry about using time as random seed.