
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
* Write a non-virtual public template function to wrap the rng
It's difficult to explain concisely - here's what the code should look
like (untested - just for explanation):
template<class ResultType>
class runtime_generator {
public:
template <class T>
explicit runtime_generator(T& rng)
: min_(rng.min()), max_(rng.max()), impl(rng) {
}
ResultType min() const { return min_; }
ResultType max() const { return max_; }
ResultType operator()() { return impl(); }
private:
ResultType min_, max_;
boost::function