Boost logo

Boost Users :

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


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

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?


Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at