Boost logo

Boost :

Subject: Re: [boost] Strange use of random values in regression test ...
From: Thijs van den Berg (thijs_at_[hidden])
Date: 2014-04-21 13:34:20

On 21 Apr 2014, at 18:55, Chris Cooper <chris.cooper_at_[hidden]> wrote:

> The test_main() of libs/utility/operators_test.cpp loops 1000 times, running a variety of tests on random values. However, since the randomizer (boost::minstd_rand) is instantiated inside the loop, it appears that the randomizer is re-seeded for each loop, meaning it runs the test 1000x with the exact same values each time.
> I’m not 100% familiar with the boost random value generators, am I missing something? Or should the boost::minstd_rand be instantiated outside the loop?
> I’m happy to add this as a boost bug if my understanding is correct …
> Thanks,
> Chris

Yes you need to put it outside the loop. When the random object is created it’s set to the same default seed.

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