Boost logo

Boost :

From: Jens Maurer (Jens.Maurer_at_[hidden])
Date: 2001-04-03 11:21:10


nbecker_at_[hidden] wrote:

> for example,
>
> class normal_distribution {
> ...
> uniform_01<base_type, RealType> _rng;
>
> So _rng will be a copy of the rng passed.

I believe this is not so.
The normal_distribution constructor takes a (non-const) reference
to base_type (i.e. the underlying RNG). Also, the uniform_01
constructor to which this RNG is passed also takes a (non-const)
reference to this type. The base RNG is also stored as a
(non-const) reference within uniform_01. normal_distribution
has a value member of type uniform_01, which embeds this
reference.

Could you please elaborate at what source line you think a copy
is being passed?
I once had effects which led me to believe that the RNG is copied
somewhere, but this was with gcc only and I have been unable
to find out where the copy might happen. I'd be happy if you
could point out where the copy takes place.

> Wouldn't it be better if _rng was a reference to allow for shared
> state?

I believe that the current random number library does so in all
instances.

Jens Maurer


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