-
Notifications
You must be signed in to change notification settings - Fork 29
/
numeric.html
51 lines (47 loc) · 2.45 KB
/
numeric.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<cxx-clause id="numeric">
<h1>Numerics library</h1>
<cxx-section id="rand">
<h1>Random number generation</h1>
<cxx-section id="rand.syn">
<h1>Header <code><experimental/random></code> synopsis</h1>
<pre><code>#include <random>
namespace std::experimental::inline fundamentals_v3 {
<cxx-ref insynopsis="" to="rand.randint"></cxx-ref>
template <class IntType>
IntType randint(IntType a, IntType b);
void reseed();
void reseed(default_random_engine::result_type value);
} // namespace std::experimental::inline fundamentals_v3</code></pre>
</cxx-section>
<cxx-section id="rand.randint">
<h1>Function template <code>randint</code></h1>
<p>A separate <dfn>per-thread engine</dfn> of type <code>default_random_engine</code>
(<cxx-ref in="cxx" to="rand.predef"></cxx-ref>), initialized to an
unpredictable state, shall be maintained for each thread.</p>
<cxx-function>
<cxx-signature>template<class IntType>
IntType randint(IntType a, IntType b);</cxx-signature>
<cxx-mandates>
The template argument meets the requirements for a template parameter named
<code>IntType</code> in <cxx-ref in="cxx" to="rand.req.genl"></cxx-ref>.
</cxx-mandates>
<cxx-preconditions><code>a</code> ≤ <code>b</code>.</cxx-preconditions>
<cxx-returns>A random integer <var>i</var>, <code>a</code> ≤ <var>i</var> ≤ <code>b</code>,
produced from a thread-local instance of <code>uniform_int_distribution<IntType></code>
(<cxx-ref in="cxx" to="rand.dist.uni.int"></cxx-ref>) invoked with the
per-thread engine.</cxx-returns>
</cxx-function>
<cxx-function>
<cxx-signature>void reseed();</cxx-signature>
<cxx-signature>void reseed(default_random_engine::result_type value);</cxx-signature>
<cxx-effects>Let <code>g</code> be the per-thread engine. The first
form sets <code>g</code> to an unpredictable state. The second form
invokes <code>g.seed(value)</code>.</cxx-effects>
<cxx-postconditions>Subsequent calls to <code>randint</code> do not
depend on values produced by <code>g</code> before calling <code>reseed</code>.
<cxx-note><code>reseed</code> also resets any instances of <code>uniform_int_distribution</code>
used by <code>randint</code>.</cxx-note></cxx-postconditions>
</cxx-function>
</cxx-section>
</cxx-section>
</cxx-clause>