|
Boost Users : |
Subject: Re: [Boost-users] [Random] Passing an arbitrary uniform random number generator to a function
From: Marco Guazzone (marco.guazzone_at_[hidden])
Date: 2010-04-28 10:19:18
On Tue, Apr 27, 2010 at 1:50 PM, Joseph Gauterin
<joseph.gauterin_at_[hidden]> wrote:
> Looks like you need some sort of type erasure (Steve's suggestion uses
> boost::function for that):
>
> * Create a class that can be passed to uniform_real as a generator -
> that is what Steve's runtime_generator class is for.
> * Give runtime_generator a constructor that takes a single argument of
> a template type, initialize min_ and max_ from that and store the
> argument in impl (that will compile if the argument is a rng that
> follows the correct conventions)
> * Write the virtual function you wanted taking an argument of type
> runtime_generator<double>& - but make it private
Why should the virtual function be private?
I suppose the reason to use a virtual function is:
* to make it overridable in a derived class
* to call it via runtime polymorphism.
Making it private don't see how it could work
Thank you very much
Cheers,
-- Marco
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