[random] Do all RNG implement a base class?

Hi, I am currently working on some cryptography algorithms for boost, I need a class such that: template < class RNG > class wiper { private: static RNG default_rng; public: void wipe(void *buffer, std::size_t count, RNG& specific_rng = default_rng) { . . . if( some_thing_is_true ) specific_rng.get_the_next_number_in_sequence(); . . } }; So I would like a provide the class with a template class (RNG) that is the base of random number generation. However, I looked at random number generators on [boost][random] but they don't seem to implement a base class! Am I right or I have mised something? regards

On Thu, Jun 19, 2008 at 08:12, Kasra (Math & ComSci) <kasra_n500@yahoo.com> wrote:
However, I looked at random number generators on [boost][random] but they don't seem to implement a base class! Am I right or I have mised something?
Probably not. The "Boost Way" is to have them all have the same interface, so that templates can use them, but not to use a base class, since virtual is expensive (to call in those reference parameters), limiting (in that they all have to use the same data types), and adds space overhead (for the vtable). And you can always wrap up a template into a virtual interface if you need it, and it'll be just as efficient as if it were originally virtual. The other way doesn't work. Just template on the RNG and all is good.
participants (2)
-
Kasra (Math & ComSci)
-
Scott McMurray