Title
[fund.ts.v3] default_random_engine is overspecified for per-thread engine
Status
open
Section
[rand.util.randint]
Submitter
Zhihao Yuan

Created on 2019-12-10.00:00:00 last changed 24 months ago

Messages

Date: 2022-11-30.17:53:33

Proposed resolution:

This wording is relative to N4840.

  1. Modify [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 [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]

Date: 2022-11-15.00:00:00

[ 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.

Date: 2022-10-15.00:00:00

[ 2022-10-19; Reflector poll ]

Set status to "Tentatively NAD" based on LEWG recommendation and reflector poll.

Date: 2020-05-15.00:00:00

[ 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
Date: 2020-01-05.16:13:01

[ 2020-01 Priority set to 3 and assigned to LEWG after review on the reflector. ]

Date: 2019-12-10.00:00:00

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.

History
Date User Action Args
2022-11-30 17:53:33adminsetmessages: + msg13131
2022-11-30 17:53:33adminsetstatus: nad -> open
2022-10-19 20:26:42adminsetmessages: + msg12874
2022-10-19 20:26:42adminsetstatus: open -> nad
2020-05-31 09:54:47adminsetmessages: + msg11319
2020-05-31 09:54:47adminsetstatus: lewg -> open
2020-01-05 16:13:01adminsetmessages: + msg10908
2020-01-05 16:13:01adminsetstatus: new -> lewg
2019-12-12 19:07:08adminsetmessages: + msg10887
2019-12-10 00:00:00admincreate