##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# C++ concepts: UniformRandomBitGenerator

From cppreference.com
< cpp‎ | concept

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).

### [edit] 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()`.
G::max() | `T` | Returns the largest value that G's operator() may return. The value is strictly greater than `G::min()`
g() | `T` | Returns a value in the closed interval [G::min(), G::max()]. Has amortized constant complexity.

### [edit] Notes

All `RandomNumberEngine`s satisfy this concept.

### [edit] Standard library

The following standard library facilities expect a `UniformRandomBitGenerator` type.

random_shuffle shuffle (until C++17)(C++11) | randomly re-orders elements in a range (function template) [edit]
generate_canonical (C++11) | evenly distributes real values of given precision across [0, 1) (function template) [edit]
uniform_int_distribution (C++11) | produces integer values evenly distributed across a range (class template) [edit]
uniform_real_distribution (C++11) | produces real values evenly distributed across a range (class template) [edit]
all other random number distributions

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

random_device | non-deterministic random number generator using hardware entropy source (class) [edit]

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=cpp/concept/UniformRandomBitGenerator&oldid=86190"