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

58 lines
2.6 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.urng]
# 29 Numerics library [[numerics]](./#numerics)
## 29.5 Random number generation [[rand]](rand#req.urng)
### 29.5.3 Requirements [[rand.req]](rand.req#urng)
#### 29.5.3.3 Uniform random bit generator requirements [rand.req.urng]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L1771)
A [*uniform random bit generator*](#def:uniform_random_bit_generator)g of type G is a function object
returning unsigned integer values
such that each value
in the range of possible results
has (ideally) equal probability
of being returned[.](#1.sentence-1)
[*Note [1](#note-1)*:
The degree to which g's results
approximate the ideal
is often determined statistically[.](#1.sentence-2)
— *end note*]
template<class G>concept [uniform_random_bit_generator](#concept:uniform_random_bit_generator "29.5.3.3Uniform random bit generator requirements[rand.req.urng]") =[invocable](concept.invocable#concept:invocable "18.7.2Concept invocable[concept.invocable]")<G&> && [unsigned_integral](concepts.arithmetic#concept:unsigned_integral "18.4.7Arithmetic concepts[concepts.arithmetic]")<invoke_result_t<G&>> &&requires {{ G::min() } -> [same_as](concept.same#concept:same_as "18.4.2Concept same_­as[concept.same]")<invoke_result_t<G&>>; { G::max() } -> [same_as](concept.same#concept:same_as "18.4.2Concept same_­as[concept.same]")<invoke_result_t<G&>>; requires bool_constant<(G::min() < G::max())>::value; };
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L1797)
Let g be an object of type G[.](#2.sentence-1)
G models[uniform_random_bit_generator](#concept:uniform_random_bit_generator "29.5.3.3Uniform random bit generator requirements[rand.req.urng]") only if
- [(2.1)](#2.1)
G::min() <= g(),
- [(2.2)](#2.2)
g() <= G::max(), and
- [(2.3)](#2.3)
g() has amortized constant complexity[.](#2.sentence-2)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L1808)
A class G meets the [*uniform random bit generator*](#def:uniform_random_bit_generator) requirements ifG models [uniform_random_bit_generator](#concept:uniform_random_bit_generator "29.5.3.3Uniform random bit generator requirements[rand.req.urng]"),invoke_result_t<G&> is an unsigned integer type ([[basic.fundamental]](basic.fundamental "6.9.2Fundamental types")),
andG provides a nested [*typedef-name*](dcl.typedef#nt:typedef-name "9.2.4The typedef specifier[dcl.typedef]") result_type that denotes the same type as invoke_result_t<G&>[.](#3.sentence-1)