[random] number generator as static class member

Dear list users, I have attached a reduced case of what I want to do. Basically, I thought it would be a good idea to have one general number generator that I attach to specific distributions in my member functions according to my needs (uniform_01 in this example, but I also want to use others). So for example I do the following in my real code, where 'rng' is my static member object: typedef boost::lagged_fibonacci607 rand_gen; boost::bernoulli_distribution<double> b_dist(p); boost::variate_generator<rand_gen&, boost::bernoulli_distribution<double> > bool_gen(MyClass::rng, b_dist); boost::uniform_smallint<short unsigned> in_dist(0, this->nodes_in - 1); boost::variate_generator<rand_gen&, boost::uniform_smallint<short unsigned> > in_gen(MyClass::rng, in_dist); Unfortunately, as the code I attached demonstrates, every time I do that the original state of the 'rng' seems to be used. Do you have suggestions for fixing this? Thank you in advance, Moritz
participants (1)
-
Moritz Beber