Title
Issues in 26.4.7.1 [rand.util.seedseq](6)
Status
resolved
Section
[rand.util.seedseq]
Submitter
Stephan Tolksdorf

Created on 2008-02-18.00:00:00 last changed 162 months ago

Messages

Date: 2011-04-27.21:19:46

Rationale:

Addressed by N2836 "Wording Tweaks for Concept-enabled Random Number Generation in C++0X".

Date: 2010-10-21.18:28:33

Proposed resolution:

Replace [rand.util.seedseq] paragraph 6 with:

Effects: Constructs a seed_seq object by effectively concatenating the low-order u bits of each of the elements of the supplied sequence [begin, end) in ascending order of significance to make a (possibly very large) unsigned binary number b having a total of n bits, and then carrying out the following algorithm:

for( v.clear(); n > 0; n -= 32 ) v.push_back(b mod 232), b /= 232;

Date: 2010-10-21.18:28:33

[ post Bellevue: Bill provided wording. ]

This issue is made moot if 803 is accepted.

Date: 2010-12-05.14:14:49

[ Bellevue: ]

Move to Open: Bill will try to propose a resolution by the next meeting.

Date: 2008-02-18.00:00:00

The for-loop in the algorithm specification has n iterations, where n is defined to be end - begin, i.e. the number of supplied w-bit quantities. Previous versions of this algorithm and the general logic behind it suggest that this is an oversight and that in the context of the for-loop n should be the number of full 32-bit quantities in b (rounded upwards). If w is 64, the current algorithm throws away half of all bits in b. If w is 16, the current algorithm sets half of all elements in v to 0.

There are two more minor issues:

  • Strictly speaking end - begin is not defined since InputIterator is not required to be a random access iterator.
  • Currently all integral types are allowed as input to the seed_seq constructor, including bool. IMHO allowing bools unnecessarily complicates the implementation without any real benefit to the user. I'd suggest to exclude bools as input.
History
Date User Action Args
2010-12-05 14:14:49adminsetstatus: nad editorial -> resolved
2010-10-21 18:28:33adminsetmessages: + msg3818
2010-10-21 18:28:33adminsetmessages: + msg3817
2010-10-21 18:28:33adminsetmessages: + msg3816
2010-10-21 18:28:33adminsetmessages: + msg3815
2008-02-18 00:00:00admincreate