Boost logo

Boost :

From: Matthias Troyer (troyer_at_[hidden])
Date: 2002-09-09 17:56:47


Always wrapping the generator makes sense, but does not solve
the problem that we sometimes need to go back to an exact
copy of the original generator.

I have thought more about it, and the only option seems to
have the user of the libraries make copies of the generator
when needed. Thus, instead of storing a copy in the library
code, and reuse it later, we have to rely on the user to
correctly pass an identical copy of the generator to
each function where it is needed - with the possibility
of errors if the user does not correctly copy the
generator. I don't see any other solution myself.

Matthias

On Monday, Sep 9, 2002, at 13:30 US/Pacific, Jens Maurer wrote:

>
> Interesting. I'm not sure I have a solution,
> except to always wrap the base generator to get
> consistent results (reference semantics).
>
> Jens Maurer
>
>
> Matthias Troyer wrote:
>>
>> Begin forwarded message:
>>
>>> From: Matthias Troyer <troyer_at_[hidden]>
>>> Date: Sun May 12, 2002 07:55:53 PM Europe/Zurich
>>> To: boost_at_[hidden]
>>> Subject: [boost] Generator copy constructor semantics
>>> Reply-To: boost_at_[hidden]
>>>
>>> Hi all,
>>>
>>> When using boost::random for a generic eigenvalue library that
>>> we are developing (http://www.comp-phys.org/software/ietl)
>>> we realized an issue regarding copy constructors of
>>> Boost random number generators in particular, and actually
>>> all generators.
>>>
>>> The definition of std::generate in the C++ standard:
>>>
>>> template<class ForwardIterator, class Generator>
>>> void generate(ForwardIterator first, ForwardIterator last,
>>> Generator gen);
>>>
>>> requires Generator to be copy-constructible. But what is
>>> the semantics of the copy constructor? If we call
>>> generate twice, do we get the same sequence or not:
>>>
>>> std::vector<T> x(100);
>>> std::vector<T> y(100);
>>>
>>> std:


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