Files
2025-10-25 03:02:53 +03:00

83 lines
4.0 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[rand.req.seedseq]
# 29 Numerics library [[numerics]](./#numerics)
## 29.5 Random number generation [[rand]](rand#req.seedseq)
### 29.5.3 Requirements [[rand.req]](rand.req#seedseq)
#### 29.5.3.2 Seed sequence requirements [rand.req.seedseq]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L1638)
A [*seed sequence*](#def:seed_sequence "29.5.3.2Seed sequence requirements[rand.req.seedseq]") 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[.](#1.sentence-1)
[*Note [1](#note-1)*:
Such an object provides a mechanism
to avoid replication of streams of random variates[.](#1.sentence-2)
This can be useful, for example, in applications
requiring large numbers of random number engines[.](#1.sentence-3)
— *end note*]
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L1653)
A class S meets the requirements
of a seed sequence
if the expressions shown
in Table [126](#tab:rand.req.seedseq "Table 126: Seed sequence requirements") are valid and have the indicated semantics,
and if S also meets all other requirements
of [rand.req.seedseq][.](#2.sentence-1)
In Table [126](#tab:rand.req.seedseq "Table 126: Seed sequence requirements") and throughout this subclause:
- [(2.1)](#2.1)
T is the type named by S's associated result_type;
- [(2.2)](#2.2)
q is a value of type S and r is a value of type S or const S;
- [(2.3)](#2.3)
ib and ie are input iterators
with an unsigned integer value_type of at least 32 bits;
- [(2.4)](#2.4)
rb and re are mutable random access iterators
with an unsigned integer value_type of at least 32 bits;
- [(2.5)](#2.5)
ob is an output iterator;
and
- [(2.6)](#2.6)
il is a value of type initializer_list<T>[.](#2.sentence-2)
Table [126](#tab:rand.req.seedseq) — Seed sequence requirements [[tab:rand.req.seedseq]](./tab:rand.req.seedseq)
| [🔗](#tab:rand.req.seedseq-row-1)<br>**Expression** | **Return type** | **Pre/post-condition** | **Complexity** |
| --- | --- | --- | --- |
| [🔗](#tab:rand.req.seedseq-row-2)<br>S::result_type | T | T is an [unsigned integer type](basic.fundamental#def:type,unsigned_integer "6.9.2Fundamental types[basic.fundamental]") of at least 32 bits[.](#tab:rand.req.seedseq-row-2-column-3-sentence-1) | |
| [🔗](#tab:rand.req.seedseq-row-3)<br>S() | | Creates a seed sequence with the same initial state as all other default-constructed seed sequences of type S[.](#tab:rand.req.seedseq-row-3-column-3-sentence-1) | constant |
| [🔗](#tab:rand.req.seedseq-row-4)<br>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)[.](#tab:rand.req.seedseq-row-4-column-3-sentence-1) | O(ie−ib) |
| [🔗](#tab:rand.req.seedseq-row-5)<br>S(il) | | Same as S(il.begin(), il.end())[.](#tab:rand.req.seedseq-row-5-column-3-sentence-1) | same as S(il.begin(), il.end()) |
| [🔗](#tab:rand.req.seedseq-row-6)<br>q.generate(rb,re) | void | Does nothing if rb == re[.](#tab:rand.req.seedseq-row-6-column-3-sentence-1)<br>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[.](#tab:rand.req.seedseq-row-6-column-3-sentence-2) | O(re−rb) |
| [🔗](#tab:rand.req.seedseq-row-7)<br>r.size() | size_t | The number of 32-bit units that would be copied by a call to r.param[.](#tab:rand.req.seedseq-row-7-column-3-sentence-1) | constant |
| [🔗](#tab:rand.req.seedseq-row-8)<br>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[.](#tab:rand.req.seedseq-row-8-column-3-sentence-1) | O(r.size()) |