Namespaces
Variants
Actions

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

From cppreference.com
< cpp‎ | named req
 
 
C++ named requirements
 

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

Contents

[edit] Requirements

The type G satisfies UniformRandomBitGenerator if

Given g, a value of type G, all following conditions are satisfied:

  • G::result_type is valid, and denotes an unsigned integer type.
  • The following expressions must be valid and have their specified effects:
(until C++20)
 Expression  Type Requirements
G::min() G::result_type 
  • Yields the smallest value that G's operator() may return. 
  • The result value is strictly less than G::max().
  • The expression must be a constant expression.
G::max() G::result_type
  • Yields the largest value that G's operator() may return.
  • The result value is strictly greater than G::min().
  • The expression must be a constant expression.
g() G::result_type
  • Returns a value in the closed interval [G::min()G::max()].
  • Has amortized constant complexity.

All following conditions are satisfied:

  • G models