This page is a snapshot from the LWG issues list, see theLibrary Active Issues List for more information and the meaning ofC++11 status.
Section: 29.5.4[rand.eng]Status:C++11Submitter: BSIOpened: 2010-08-25Last modified: 2016-01-28
Priority:Not Prioritized
View all otherissues in [rand.eng].
View all issues withC++11 status.
Discussion:
Addresses GB-121
All the random number engine types in this clause have aconstructor taking an unsigned integer type, and aconstructor template for seed sequences. This means thatan attempt to create a random number engine seeded byan integer literal must remember to add the appropriateunsigned suffix to the literal, as a signed integer willattempt to use the seed sequence template, yieldingundefined behaviour, as per 26.5.1.1p1a. It would behelpful if at least these anticipated cases produced adefined behaviour, either an erroneous program withdiagnostic, or a conversion to unsigned int forwarding tothe appropriate constructor.
[2010-11-03 Daniel comments and provides a proposed resolution:]
I suggest to apply a similar solution as recently suggested for1234(i).It is basically a requirement for an implementation to constrain the template.
[2010-11-04 Howard suggests to use!is_convertible<Sseq, result_type>::valueas minimum requirement instead of the originally proposed!is_scalar<Sseq>::value.This would allow for a user-defined typeBigNum, that is convertible toresult_type,to be used as argument for a seed instead of a seed sequence. The wording has been updated to reflect this suggestion.]
[2010 Batavia: There were some initial concerns regarding the portability and reproducibility of results when seeded with a negative signed value, but these concerns were allayed after discussion. Thus, afterreviewing the issue, the working group concurred with the issue's Proposed Resolution. ]
[Adopted at 2010-11 Batavia]
Proposed resolution:
Add the following paragraph at the end of 29.5.4[rand.eng]:
5 Each template specified in this section [rand.eng] requires one or more relationships, involving the value(s) ofits non-type template parameter(s), to hold. A program instantiating any of these templates is ill-formed ifany such required relationship fails to hold.
? For every random number engine and for every random number engine adaptor
Xdefined in this sub-clause [rand.eng] and in sub-clause [rand.adapt]:
- If the constructor
template<class Sseq> explicit X(Sseq& q);is called with a type
Sseqthat does not qualify as a seed sequence, then this constructor shall not participate in overload resolution.- If the member function
template<class Sseq> void seed(Sseq& q);is called with a type
Sseqthat does not qualify as a seed sequence, then this function shall not participate in overload resolution.The extent to which an implementation determines that a type cannot be a seed sequence is unspecified,except that as a minimum a type shall not qualify as seed sequence, if it is implicitly convertibleto
X::result_type.