
Joseph Wakeling wrote:
Hello,
Suppose that I have a function that takes a uniform random number generator as an argument, e.g.
double foo(mt19937 &urng) { double x = uniform_real<double> (0.0, 10.0) (urng); double y = uniform_real<double> (5.0, 7.0) (urng);
return (x*y); }
Is there a way to make the choice of random number generator arbitrary (i.e. not limited to mt19937) without making the function a template? Alternatively, is there a better way of passing around the basic uniform random number generator?
The reason for the no-template rule is that I would like to pass a URNG to a virtual function in a class, and I would really not like to have to make the class itself a template dependent on the type of URNG.
Can someone recommend a solution?
Thanks and best wishes,
-- Joe member func can be template without class class being template.