Boost logo

Boost :

Subject: Re: [boost] [config] std::shuffle support
From: Edward Diener (eldiener_at_[hidden])
Date: 2016-11-07 09:54:23


On 11/7/2016 7:28 AM, Peter Dimov wrote:
> Andrey Semashev wrote:
>
>> FWIW, in Boost.Log I'm using my local random_shuffle[1] regardless of
>> the standard library version. Maybe that would be a better solution
>> than conditioning your code on config macros.
>>
>> [1]: https://github.com/boostorg/log/blob/develop/src/core.cpp#L60
>
> The standard random_shuffle doesn't use rng() % n though, it uses
> rng(n). rng() % n is non-uniform in general.

So substituting:

Iterator where = begin + rng(it - begin + 1u);

in Andrey's code would be fine according to the current random_shuffle
implementations ?

I am just trying to fix this for libraries which I didn't write so I
have no personal stake in this.


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