This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of Open status.
default_random_engine
is overspecified for per-thread engineSection: 99 [fund.ts.v3::rand.util.randint] Status: Open Submitter: Zhihao Yuan Opened: 2019-12-10 Last modified: 2022-11-30
Priority: 3
View all issues with Open status.
Discussion:
Addresses: fund.ts.v3
Although "implementation may select this type on the basis of performance, size, quality, or any combination of such factors," but changing this typedef is an ABI-break for implementations. Specifying per-thread engine to use this typedef results in losses of performance, size, and/or quality.
Since this type is not involved inrandint
facilities' interface (other than its member
typedef), the current specification should be relaxed.
[2020-01 Priority set to 3 and assigned to LEWG after review on the reflector.]
[2020-05-28; LEWG issue reviewing]
LEWG issue processing voted to reject 3357 as NAD. Status change to Open.
Reject LWG3357 as NAD SF F N A SA 1 10 4 2 1
[2022-10-19; Reflector poll]
Set status to "Tentatively NAD" based on LEWG recommendation and reflector poll.
[2022-11-30; LWG telecon]
Prefer to keep an open issue for the TS than to possibly forget to address it if this feature is proposed for the IS some day.
Proposed resolution:
This wording is relative to N4840.
Modify 11.1.1 [fund.ts.v3::rand.syn], header <experimental/random>
synopsis, as indicated:
#include <random> namespace std::experimental { inline namespace fundamentals_v3 { // 10.1.2.1, Function template randint template <class IntType> IntType randint(IntType a, IntType b); void reseed(); void reseed(default_random_engine::result_typeuint_fast32_t value); } // inline namespace fundamentals_v3 } // namespace std::experimental
Modify 99 [fund.ts.v3::rand.util.randint] as indicated:
-1- A separate per-thread engine of
[…]typeunspecified type that meets the requirements of random number engine (C++17 [rand.req.eng]), initialized to an unpredictable state, shall be maintained for each thread. [Note: The implementation may choose the engine type on the basis of performance, size, quality, or any combination of such factors, so as to provide at least acceptable engine behavior for relatively casual, inexpert, and/or lightweight use. — end note]default_random_engine
(C++17 §29.6.5)void reseed(); void reseed(default_random_engine::result_typeuint_fast32_t value);-7- Effects: Let
-8- Postconditions: Subsequent calls tog
be the per-thread engine. The first form setsg
to an unpredictable state. The second form invokesg.seed(value)
.randint
do not depend on values produced byg
before calling reseed. [Note:reseed
also resets any instances ofuniform_int_distribution
used byrandint
. — end note]