C++ named requirements: UniformRandomBitGenerator (since C++11)

From cppreference.com
< cpp‎ | named req
 
 
C++ named requirements
Basic
Type properties
Library-Wide
Container
Container Elements
(C++11)

Iterator
Stream I/O
Formatters
(C++20)
Random Numbers
(C++11)    
UniformRandomBitGenerator
(C++11)    
Concurrency
(C++11)
(C++11)
Ranges
Other
(C++11)


 

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 any random number distribution in order to obtain a random number (formally, a random variate).

Requirements

The type G satisfies UniformRandomBitGenerator if

Given

  • T, the type named by G::result_type
  • g, a value of type G

The following expressions must be valid and have their specified effects

Expression Return type Requirements
G::result_type T T is an unsigned integer type
G::min() T Returns the smallest value that G's operator() may return. The value is strictly less than G::max(). The function must be constexpr.
G::max() T Returns the largest value that G's operator() may return. The value is strictly greater than G::min(). The function must be constexpr.
g() T Returns a value in the closed interval [G::min(), G::max()]. Has amortized constant complexity.

Notes

All RandomNumberEngines satisfy this requirement.

Standard library

The following standard library facilities expect a UniformRandomBitGenerator type.

(until C++17)(C++11)
randomly re-orders elements in a range
(function template)
evenly distributes real values of given precision across [01)
(function template)
produces integer values evenly distributed across a range
(class template)
produces real values evenly distributed across a range
(class template)
all other random number distributions

The following standard library facilities satisfy UniformRandomBitGenerator without additionally satisfying RandomNumberEngine:

non-deterministic random number generator using hardware entropy source
(class)

See also

specifies that a type qualifies as a uniform random bit generator
(concept)