|
303 | 303 | <code class="classname">minstd_rand0</code>. |
304 | 304 | </p><p> |
305 | 305 | <span class="emphasis"><em> 26.5.6 [rand.device] </em></span> |
306 | | - The default <code class="code">token</code> argument to the |
307 | | - <code class="classname">random_device</code> constructor is |
308 | | - <code class="literal">"default"</code>. Other valid arguments are |
309 | | - <code class="literal">"/dev/random"</code> and <code class="literal">"/dev/urandom"</code>, |
310 | | - which determine the character special file to read random bytes from. |
311 | | - The <code class="literal">"default"</code> token will read bytes from a hardware |
312 | | - RNG if available (currently this only supports the IA-32 RDRAND |
313 | | - instruction) otherwise it is equivalent to |
314 | | - <code class="literal">"/dev/urandom"</code>. |
| 306 | + The <code class="code">token</code> parameter of the |
| 307 | + <code class="classname">random_device</code> constructor can be used to select |
| 308 | + a specific source of random bytes. The valid token values are shown |
| 309 | + in the list below. |
| 310 | + The default constructor uses the token <code class="literal">"default"</code>. |
| 311 | + </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="literal">"default"</code></span></dt><dd> |
| 312 | + Select the first available source from the other entries below. |
| 313 | + This is the only token that is always valid. |
| 314 | + </dd><dt><span class="term"><code class="literal">"rand_s"</code></span></dt><dd> |
| 315 | + Use the MSVCRT <code class="function">rand_s</code> function. |
| 316 | + This token is only valid for mingw-w64 targets. |
| 317 | + </dd><dt><span class="term"><code class="literal">"rdseed"</code>, </span><span class="term"><code class="literal">"rdrand"</code> or <code class="literal">"rdrnd"</code></span></dt><dd> |
| 318 | + Use the IA-32 <code class="literal">RDSEED</code> or <code class="literal">RDRAND</code> |
| 319 | + instruction to read from an on-chip hardware random number generator. |
| 320 | + These tokens are only valid for x86 and x86_64 targets when both |
| 321 | + the assembler and CPU support the corresponding instruction. |
| 322 | + </dd><dt><span class="term"><code class="literal">"/dev/urandom"</code>, </span><span class="term"><code class="literal">"/dev/random"</code></span></dt><dd> |
| 323 | + Use the named character special file to read random bytes from. |
| 324 | + These tokens are only valid when the device files are present |
| 325 | + and readable by the current user. |
| 326 | + </dd><dt><span class="term"><code class="literal">"mt19937"</code>, </span><span class="term">seed value</span></dt><dd> |
| 327 | + When no source of nondeterministic random numbers is available a |
| 328 | + <code class="classname">mersenne_twister_engine</code> will be used. |
| 329 | + An integer seed value can be used as the token and will be converted |
| 330 | + to an <code class="code">unsigned long</code> using <code class="function">strtoul</code>. |
| 331 | + These tokens are only valid when no other source of random bytes |
| 332 | + is available. |
| 333 | + </dd></dl></div><p> |
315 | 334 | An exception of type <code class="classname">runtime_error</code> will be |
316 | | - thrown if a <code class="classname">random_device</code> object cannot open |
317 | | - or read from the source of random bytes. |
| 335 | + thrown if a <code class="classname">random_device</code> object is constructed |
| 336 | + with an invalid token, or if it cannot open or read from the source |
| 337 | + of random bytes. |
318 | 338 | </p><p> |
319 | 339 | <span class="emphasis"><em>26.5.8.1 [rand.dist.general]</em></span> |
320 | 340 | The algorithms used by the distributions should be documented here. |
|
0 commit comments