Boost logo

Boost Users :

From: John Smith (jsmith1975_at_[hidden])
Date: 2005-08-02 17:57:30


Hello:

I am trying to use boost::variate_generator so that the generator and
distribution can
be set dynamically at run time.

Currently, I am doing this using the following from
http://www.boost.org/libs/random/random_speed.cpp

Classes: RandomGenBase, DynamicRandomGenerator, GenericRandomGenerator
Function: make_dynamic(URNG & rng, const Dist& d)

Then I am able to do:

boost::mt19937 rng;
iosim::GenericRandomGenerator<int> g_int;
g_int.set(iosim::make_dynamic(rng, boost::uniform_int<>(-2,4)));
(use g_int()...)

g_int.set(iosim::make_dynamic(rng, boost::geometric_distribution<>(0.5)));
(use g_int()...)

Is there a better way of doing this?

Thanks.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net