I am currently looking into new c++11
random
library. For simplification, I created following class
class my_rand {
private:
std::mt19937_64 eng;
public:
my_rand() {
std::array<int, std::mt19937::state_size> seed_data;
std::random_device rd;
std::generate_n(seed_data.data(), seed_data.size(), std::ref(rd));
std::seed_seq seq(std::begin(seed_data), std::end(seed_data));
this->eng.seed(seq);
};
unsigned long long operator() () {
return this->eng();
};
};
so that I can just do my_rand rand;
once and then repeatedly call rand()
to generate random numbers.
However, now I want to use std::uniform_int_distribution
to set bound to numbers I get. It seams obvious to specify bounds while creating the object, so that invocations stay the same. The problem is, if I add private member (something like std::uniform_int_distribution<long long> uid;
) then later in constructor I will not be able to set bounds because uid
will already be initialized. I could not find method of std::uniform_int_distribution
which allowed to set limits after it is created.
I may well be missing some point here, so thanks in advance for any help.