Boost logo

Boost :

From: Beman Dawes (beman_at_[hidden])
Date: 1998-12-09 20:31:43

At 07:08 PM 12/9/98 +0000, Kevlin Henney wrote:

>I am not sure that this is a fair characterisation of the algorithm
>which is a linear feedback shift register which has well known
>as a competent and efficient generator. The generator in question
uses a 32
>bit LSFR to produce bits, and so standard usage is to accumulate the
>as necessary to create an integer of the appropriate size: no
>is needed for different types if the underlying bit generation is
sound; it
>is needed if you mess with the LSFR size and composition -- no
intention of
>doing that!
>The pseudo-container suggestion in the original work proved a point
>generated sequences, but is not essential to the random number
issue. I
>prefer the suggestion that a counting adapter, taking begin iterator
>count, would be more appropriate as this has general application.
This is
>definitely worth having.
>Core to the original work was the idea of generated sequence as
>and I think that is the most valuable thing, ie relationship to
>requirements, etc.
>I do not see that having alternative implementations of a random
>generator is necessarily a bad thing, esp as the one I was proposing
>different usage properties (ie template parameterisation),
>characteristics and explores a different model consistent with other
>of the standard library.
>Maybe a suitable area of convergence would be to separate out some
>and consider this as three separate layers:
>* Random number generation, using a generator function conforming to

Yes, particularly the requirements for a random number generating
function object in 25.2.11.

>* An adaptor class, templated on (and initialised by an instance of)
>random generator type, that allows a generator to be used as a
>iterator to const.

I am unsure if this separate adapter class is needed. Greg Colvin
has said in private email that he thinks the RNG class itself can
model an iterator. That would be simpler if it can be made to work.

>* An adaptor that creates the effect of a pseudo-container by taking
>begin iterator and count -- this last is more general purpose.

Yes, that seems would seem to be needed if you want, say, begin() and
end() for 1000 iterators using some specified RNG.

>What do you think?

Give it a try! Put some code together and post it to this mailing
list to see what people think of it. The feedback should be

Free Web-based e-mail groups --

Boost list run by bdawes at, gregod at, cpdaniel at, john at