Skip to content

Commit dfd78d7

Browse files
committed
New issue from Magnus Fromreide: "Seed sequence is overspecified"
1 parent 367b947 commit dfd78d7

File tree

1 file changed

+212
-0
lines changed

1 file changed

+212
-0
lines changed

xml/issue4289.xml

Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
<?xml version='1.0' encoding='utf-8' standalone='no'?>
2+
<!DOCTYPE issue SYSTEM "lwg-issue.dtd">
3+
4+
<issue num="4289" status="New">
5+
<title>Seed sequence is overspecified</title>
6+
<section>
7+
<sref ref="[rand.req.seedseq]"/>
8+
</section>
9+
<submitter>Magnus Fromreide</submitter>
10+
<date>22 Jun 2025</date>
11+
<priority>99</priority>
12+
13+
<discussion>
14+
<p>
15+
The requirements on a seed sequence are so strict that it is forbidden to initialize a random number
16+
generator directly from a hardware random number generator without lots of boiler plate and intermediary objects.
17+
<p/>
18+
The main problem is that the seed sequence requirements state that a seed sequence must be "kind of copyable"
19+
and that calls to the copy must generate the same output as calls to the original.
20+
<p/>
21+
If one checks the uses of seed sequences then nothing makes use of this capability so I propose to just drop it.
22+
<p/>
23+
There has been a previous attempt to handle this issue using <paper num="P0205"/> which preserved the old seed
24+
sequence and added a new concept that it used to seed generators. That effort stalled with the comment that
25+
it should be solved without the new `std::seed_adapter`. This DR sidesteps that whole issue by simply removing
26+
the unused requirements from the seed sequence concept.
27+
<p/>
28+
I will admit that I am unsure about the deletion of Note 1 but since it only seems to attempt to motivate the
29+
copyability I opted to let it go along with the requirements.
30+
</p>
31+
</discussion>
32+
33+
<resolution>
34+
<p>
35+
This wording is relative to <paper num="N5008"/>.
36+
</p>
37+
38+
<ol>
39+
40+
<li><p>Modify <sref ref="[rand.req.seedseq]"/> as indicated:</p>
41+
42+
<blockquote>
43+
<p>
44+
-1- A <i>seed sequence</i> is an object that <del>consumes a sequence of integer-valued data and</del>
45+
produces a requested number of unsigned integer values <tt><i>i</i></tt>, <tt>0 = i &lt; 2<sup>32</sup></tt><del>,
46+
based on the consumed data</del>.
47+
<p/>
48+
<del>[<i>Note 1</i>: Such an object provides a mechanism to avoid replication of streams of random variates. This can be
49+
useful, for example, in applications requiring large numbers of random number engines. &mdash; <i>end note</i>]</del>
50+
<p/>
51+
-2- A class `S` meets the requirements of a seed sequence if the expressions shown in
52+
Table 124 <sref ref="[tab:rand.req.seedseq]"/> are valid and have the indicated semantics, and if `S` also meets
53+
all other requirements of <sref ref="[rand.req.seedseq]"/>. In Table 124 [tab:rand.req.seedseq] and throughout
54+
this subclause:
55+
</p>
56+
<ol style="list-style-type: none">
57+
<li><p>(2.1) &mdash; `T` is the type named by `S`' s associated `result_type`;</p></li>
58+
<li><p>(2.2) &mdash; `q` is a value of type `S` <del>and `r` is a value of type `S` or `const S`</del>; <ins>and</ins></p></li>
59+
<li><p><del>(2.3) &mdash; `ib` and `ie` are input iterators with an unsigned integer `value_type` of at least 32 bits;</del></p></li>
60+
<li><p>(2.4) &mdash; `rb` and `re` are mutable random access iterators with an unsigned integer `value_type` of
61+
at least 32 bits<del>;</del><ins>.</ins></p></li>
62+
<li><p><del>(2.5) &mdash; `ob` is an output iterator; and</del></p></li>
63+
<li><p><del>(2.6) &mdash; `il` is a value of type <tt>initializer_list&lt;T&gt;</tt>.</del></p></li>
64+
</ol>
65+
<blockquote>
66+
<table border="1">
67+
<caption>Table 124 &mdash; Seed sequence requirements [tab:rand.req.seedseq]</caption>
68+
<tr>
69+
<th align="center">Expression</th>
70+
<th align="center">Return type</th>
71+
<th align="center">Pre/post-condition</th>
72+
<th align="center">Complexity</th>
73+
</tr>
74+
75+
<tr>
76+
<td>
77+
`S::result_type`
78+
</td>
79+
<td>
80+
`T`
81+
</td>
82+
<td>
83+
`T` is an unsigned integer<br/>
84+
type (<sref ref="[basic.fundamental]"/>) of at least 32 bits.
85+
</td>
86+
<td>
87+
</td>
88+
</tr>
89+
90+
<tr>
91+
<td>
92+
<del><tt>S()</tt></del>
93+
</td>
94+
<td>
95+
<tt></tt>
96+
</td>
97+
<td>
98+
<del>Creates a seed sequence with</del><br/>
99+
<del>the same initial state as all</del><br/>
100+
<del>other default-constructed seed</del><br/>
101+
<del>sequences of type `S`.</del>
102+
</td>
103+
<td>
104+
<del>constant</del>
105+
</td>
106+
</tr>
107+
108+
<tr>
109+
<td>
110+
<del>`S(ib,ie)`</del>
111+
</td>
112+
<td>
113+
<tt></tt>
114+
</td>
115+
<td>
116+
<del>Creates a seed sequence having</del><br/>
117+
<del>internal state that depends on</del><br/>
118+
<del>some or all of the bits of the</del><br/>
119+
<del>supplied sequence `[ib, ie)`.</del>
120+
</td>
121+
<td>
122+
<del>&#x1d4aa;(ie - ib)</del>
123+
</td>
124+
</tr>
125+
126+
<tr>
127+
<td>
128+
<del>`S(il)`</del>
129+
</td>
130+
<td>
131+
<tt></tt>
132+
</td>
133+
<td>
134+
<del>Same as <tt>S(il.begin(), il.end())</tt>.</del>
135+
</td>
136+
<td>
137+
<del>same as <tt>S(il.begin(), il.end())</tt></del>
138+
</td>
139+
</tr>
140+
141+
<tr>
142+
<td>
143+
<tt>q.generate(rb,re)</tt>
144+
</td>
145+
<td>
146+
<tt>void</tt>
147+
</td>
148+
<td>
149+
Does nothing if `rb == re`.<br/>
150+
Otherwise, fills the supplied<br/>
151+
sequence `[rb, re)` with 32-bit<br/>
152+
quantities <del>that depend on the</del><br/>
153+
<del>sequence supplied to the</del><br/>
154+
<del>constructor and possibly also</del><br/>
155+
<del>depend on the history of</del><br/>
156+
<del>`generate`'s previous</del><br/>
157+
<del>invocations</del>.
158+
</td>
159+
<td>
160+
&#x1d4aa;(re - rb)
161+
</td>
162+
</tr>
163+
164+
<tr>
165+
<td>
166+
<del><tt>r.size()</tt></del>
167+
</td>
168+
<td>
169+
<del><tt>size_t</tt></del>
170+
</td>
171+
<td>
172+
<del>The number of 32-bit units that</del><br/>
173+
<del>would be copied by a call to</del><br/>
174+
<del>`r.param`.</del>
175+
</td>
176+
<td>
177+
<del>constant</del>
178+
</td>
179+
</tr>
180+
181+
<tr>
182+
<td>
183+
<del><tt>r.param(ob)</tt></del>
184+
</td>
185+
<td>
186+
<del><tt>void</tt></del>
187+
</td>
188+
<td>
189+
<del>Copies to the given destination</del><br/>
190+
<del>a sequence of 32-bit units that</del><br/>
191+
<del>can be provided to the</del><br/>
192+
<del>constructor of a second object of</del><br/>
193+
<del>type `S`, and that would</del><br/>
194+
<del>reproduce in that second object</del><br/>
195+
<del>a state indistinguishable from</del><br/>
196+
<del>the state of the first object.</del>
197+
</td>
198+
<td>
199+
<del>&#x1d4aa;(r.size())</del>
200+
</td>
201+
</tr>
202+
203+
</table>
204+
205+
</blockquote>
206+
</blockquote>
207+
</li>
208+
209+
</ol>
210+
</resolution>
211+
212+
</issue>

0 commit comments

Comments
 (0)