26 Numerics library [numerics]

26.5 Random number generation [rand]

26.5.1 Requirements [rand.req]

26.5.1.2 Seed sequence requirements [rand.req.seedseq]

A seed sequence is an object that consumes a sequence of integer-valued data and produces a requested number of unsigned integer values i, 0 ≤ i < 232 , based on the consumed data. [ Note: Such an object provides a mechanism to avoid replication of streams of random variates. This can be useful, for example, in applications requiring large numbers of random number engines.  — end note ]

A class S satisfies the requirements of a seed sequence if the expressions shown in Table [tab:SeedSequence] are valid and have the indicated semantics, and if S also satisfies all other requirements of this section [rand.req.seedseq]. In that Table and throughout this section:

  1. T is the type named by S's associated result_type;

  2. q is a value of S and r is a possibly const value of S;

  3. ib and ie are input iterators with an unsigned integer value_type of at least 32 bits;

  4. rb and re are mutable random access iterators with an unsigned integer value_type of at least 32 bits;

  5. ob is an output iterator; and

  6. il is a value of initializer_list<T>.

Table 115 — Seed sequence requirements
ExpressionReturn typePre/post-conditionComplexity
S::result_type T T is an unsigned integer type ([basic.fundamental]) of at least 32 bits. compile-time
S() Creates a seed sequence with the same initial state as all other default-constructed seed sequences of type S. constant
S(ib,ie) Creates a seed sequence having internal state that depends on some or all of the bits of the supplied sequence [ib,ie). Ο(ie - ib)
S(il) Same as S(il.begin(), il.end()). same as S(il.begin(), il.end())
q.generate(rb,re) void Does nothing if rb == re. Otherwise, fills the supplied sequence [rb,re) with 32-bit quantities that depend on the sequence supplied to the constructor and possibly also depend on the history of generate's previous invocations. Ο(re - rb)
r.size() size_t The number of 32-bit units that would be copied by a call to r.param. constant
r.param(ob) void Copies to the given destination a sequence of 32-bit units that can be provided to the constructor of a second object of type S, and that would reproduce in that second object a state indistinguishable from the state of the first object. Ο(r.size())