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.

### 3357. [fund.ts.v3] `default_random_engine` is overspecified for per-thread engine

Section: 99 [fund.ts.v3::rand.util.randint] Status: Open Submitter: Zhihao Yuan Opened: 2019-12-10 Last modified: 2020-05-31

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 in `randint` 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

Proposed resolution:

This wording is relative to N4840.

1. Modify 9.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

2. Modify 99 [fund.ts.v3::rand.util.randint] as indicated:

   > -1- A separate per-thread engine of type `default_random_engine` (C++17 §29.6.5)unspecified 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]

   > […]

   >     void reseed();
   >     void reseed(default_random_engine::result_typeuint_fast32_t value);

   > > -7- Effects: Let `g` be the per-thread engine. The first form sets `g` to an unpredictable state. The second form invokes `g.seed(value)`.

   > > -8- Postconditions: Subsequent calls to `randint` do not depend on values produced by `g` before calling reseed. [Note: `reseed` also resets any instances of `uniform_int_distribution` used by `randint`. — end note]