Created on 2022-11-02.00:00:00 last changed 10 months ago
Proposed resolution:
This wording is relative to n4917.
Modify the class synopsis in [rand.eng.sub] as indicated:
namespace std { template<class UIntType, size_t w, size_t s, size_t r> class subtract_with_carry_engine { public: // types using result_type = UIntType; // engine characteristics static constexpr size_t word_size = w; static constexpr size_t short_lag = s; static constexpr size_t long_lag = r; static constexpr result_type min() { return 0; } static constexpr result_type max() { return m − 1; } static constexprresult_typeuint_least32_t default_seed = 19780503u; // constructors and seeding functions subtract_with_carry_engine() : subtract_with_carry_engine(default_seed0u) {} explicit subtract_with_carry_engine(result_type value); template<class Sseq> explicit subtract_with_carry_engine(Sseq& q); void seed(result_type value =default_seed0u); template<class Sseq> void seed(Sseq& q);
Modify [rand.eng.sub] p7 as indicated:
explicit subtract_with_carry_engine(result_type value);-7- Effects: Sets the values of , in that order, as specified below. If is then , sets to ; otherwise sets to .
To set the values , first construct e, a linear_congruential_engine object, as if by the following definition:
linear_congruential_engine<result_typeuint_least32_t, 40014u,0u,2147483563u> e(value == 0u ? default_seed : value);Then, to set each , obtain new values from successive invocations of e. Set to .
[ 2023-11-11 Approved at November 2023 meeting in Kona. Status changed: Voting → WP. ]
[ 2023-05; reflector poll ]
Status to Tentatively Ready after six votes in favour.
[ Kona 2022-11-25; Jonathan provides wording ]
[ Kona 2022-11-12; Set priority to 3 ]
The standard requires subtract_with_carry_engine<T> to use:
linear_congruential_engine<T, 40014u, 0u, 2147483563u>
where each of those values is converted to T.
This appears to mean subtract_with_carry_engine cannot be used with uint16_t, because 2147483563u cannot be converted to uint16_t without narrowing. What is the intention here? Should it be ill-formed? Should the seed engine be linear_congruential_engine<uint_least32_t, …> instead? The values from the linear_congruential_engine are used modulo 2^32 so getting 64-bit values from it is pointless, and getting 16-bit values from it doesn't compile.History | |||
---|---|---|---|
Date | User | Action | Args |
2023-11-13 14:08:10 | admin | set | messages: + msg13839 |
2023-11-13 14:08:10 | admin | set | status: voting -> wp |
2023-11-07 21:41:54 | admin | set | status: ready -> voting |
2023-11-07 20:53:14 | admin | set | messages: + msg13824 |
2023-11-07 20:53:14 | admin | set | status: new -> ready |
2022-11-25 15:40:55 | admin | set | messages: + msg13114 |
2022-11-25 15:40:55 | admin | set | messages: + msg13113 |
2022-11-12 01:08:30 | admin | set | messages: + msg13035 |
2022-11-02 00:00:00 | admin | create |