|
|
|
A uniform random bit generator is a function object returning unsigned integer values such that each value in the range of possible results has (ideally) equal probability.
Uniform random bit generators are not intended to be used as random number generators: they are used as the source of random bits (generated in bulk, for efficiency). Any uniform random bit generator may be plugged into anyrandom number distribution in order to obtain a random number (formally, a random variate).
Contents |
The typeG
satisfiesUniformRandomBitGenerator if
Giveng, a value of type
| (until C++20) |
Expression | Type | Requirements |
---|---|---|
G::min() | G::result_type |
|
G::max() | G::result_type |
|
g() | G::result_type |
|
All following conditions are satisfied:
| (since C++20) |
AllRandomNumberEngines satisfy this requirement.
The following standard library facilities expect aUniformRandomBitGenerator type.
(until C++17)(C++11) | randomly re-orders elements in a range (function template)[edit] |
(C++17) | selects N random elements from a sequence (function template)[edit] |
(C++11) | evenly distributes real values of given precision across[ 0, 1) (function template)[edit] |
(C++11) | produces integer values evenly distributed across a range (class template)[edit] |
(C++11) | produces real values evenly distributed across a range (class template)[edit] |
all other random number distributions |
The following standard library facilities satisfyUniformRandomBitGenerator without additionally satisfyingRandomNumberEngine:
(C++11) | non-deterministic random number generator using hardware entropy source (class)[edit] |
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
DR | Applied to | Behavior as published | Correct behavior |
---|---|---|---|
LWG 2154 (P0898R3) | C++11 | it was unclear whetherG::min() andG::max() are required to be constant expressions[1] | required |
(C++20) | specifies that a type qualifies as a uniform random bit generator (concept)[edit] |