Created on 2010-08-25.00:00:00 last changed 161 months ago
Proposed resolution:
Add the following paragraph at the end of [rand.eng]:
5 Each template specified in this section [rand.eng] requires one or more relationships, involving the value(s) of its non-type template parameter(s), to hold. A program instantiating any of these templates is ill-formed if any such required relationship fails to hold.
? For every random number engine and for every random number engine adaptor X defined 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 Sseq that 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 Sseq that 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 convertible to X::result_type.
[ Adopted at 2010-11 Batavia ]
[ 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, after reviewing the issue, the working group concurred with the issue's Proposed Resolution. ]
[ 2010-11-04 Howard suggests to use !is_convertible<Sseq, result_type>::value as minimum requirement instead of the originally proposed !is_scalar<Sseq>::value. This would allow for a user-defined type BigNum, that is convertible to result_type, to be used as argument for a seed instead of a seed sequence. The wording has been updated to reflect this suggestion. ]
[ 2010-11-03 Daniel comments and provides a proposed resolution: ]
I suggest to apply a similar solution as recently suggested for 1234. It is basically a requirement for an implementation to constrain the template.
Addresses GB-121
All the random number engine types in this clause have a constructor taking an unsigned integer type, and a constructor template for seed sequences. This means that an attempt to create a random number engine seeded by an integer literal must remember to add the appropriate unsigned suffix to the literal, as a signed integer will attempt to use the seed sequence template, yielding undefined behaviour, as per 26.5.1.1p1a. It would be helpful if at least these anticipated cases produced a defined behaviour, either an erroneous program with diagnostic, or a conversion to unsigned int forwarding to the appropriate constructor.
History | |||
---|---|---|---|
Date | User | Action | Args |
2011-08-23 20:07:26 | admin | set | status: wp -> c++11 |
2010-11-24 14:01:03 | admin | set | messages: + msg5433 |
2010-11-14 13:10:57 | admin | set | status: voting -> wp |
2010-11-13 01:17:02 | admin | set | status: open -> voting |
2010-11-13 01:11:40 | admin | set | status: immediate -> open |
2010-11-11 19:16:05 | admin | set | messages: + msg5331 |
2010-11-11 19:16:05 | admin | set | status: open -> immediate |
2010-11-05 18:23:50 | admin | set | messages: + msg5294 |
2010-11-03 21:20:39 | admin | set | messages: + msg5284 |
2010-11-03 21:20:39 | admin | set | messages: + msg5283 |
2010-10-24 03:04:13 | admin | set | messages: + msg4930 |
2010-08-25 00:00:00 | admin | create |