Boost logo

Boost :

From: Jeremy Day (jeremy.day_at_[hidden])
Date: 2006-08-08 12:54:25


On 8/8/06, Neal Becker <ndbecker2_at_[hidden]> wrote:
>
> template<class Engine>
> result_type operator()(Engine& eng)
>
> is sometimes awkward. It doesn't allow compile-time inquiry of the engine
> properties by the distribution class. For example, I have a distribution
> that generates an integer of random bits of a fixed width. It is awkward
> that the distribution class can't get the engine bit width.

I'm certainly no expert on generic programming or random numbers, but
couldn't you use something like this:

struct my_distribution
  {
  enum { bit_width 4 };
  //or
  int bit_width(void) { return(4); }
  //Other distribution code.
  };

Then, in your templated operator(), you could just do Engine::bit_width or
eng.bit_width().

Does that make any sense?

Jeremy


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk