Boost logo

Boost :

Subject: Re: [boost] Boost.Uuid and header-only support
From: James E. King, III (jking_at_[hidden])
Date: 2017-11-06 14:21:13


On Mon, Nov 6, 2017 at 8:38 AM, Peter Dimov via Boost <boost_at_[hidden]
> wrote:

> James E. King, III wrote:
>
>> I'm planning to change random_generator to use the header-only
>> random_device based on points made in this discussion:
>>
>> 1. It is more secure.
>> 2. I believe it is the most widely used use case: generating a uuid
>> relatively infrequently (i.e. not in bulk).
>>
>
> Thanks.
>
> Therefore it will look something like this:
>>
>> //
>> // The default random_generator uses operating-system provided entropy,
>> // is the most secure, and fastest random uuid generator for creating a
>> // small number of uuids with a single generator because it does not need
>> // expensive seeding to be effective like a PseudoRandomNumberGenerator
>> // does.
>> //
>> typedef basic_random_generator<detail::random::random_device>
>> random_generator;
>>
>
> I suggest
>
> class random_generator {
> public:
> typedef uuid result_type;
>
> random_generator();
>
> uuid operator()();
> };
>
> that is, not using basic_random_generator here at all. There is no need to
> go through a URNG in this case; random bytes can and should be obtained
> directly from the OS API.
>
> typedef basic_random_generator<mt19937> random_generator_bulk;
>>
>
> If we guarantee that this will always use mt19937, it might be better to
> just call it random_generator_mt19937.
>
>
And I just wrapped up my changes with random_generator_bulk too.

I'm not certain that it is necessary to make random_generator a separate
class like this.
As it is, I have removed most of the additional weight from
basic_random_generator like
the variate and uniform code. I'll turn the crank one more time however to
see if I can
make any further improvements.

- Jim


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