C++ named requirements: RandomNumberDistribution (since C++11)
From cppreference.com
 
 
 
 
 
 C++ 
 Feature test macros (C++20)
 Concepts library (C++20)
 Metaprogramming library (C++11)
 Ranges library (C++20)
 Filesystem library (C++17)
 Concurrency support library (C++11)
 Execution control library (C++26)
C++ named requirements 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
 
 
 
 
 
 
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
  (C++11)
(C++11)
(C++11)
(C++17)
(C++11)
  (C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++17)
(C++20)
(C++20)
(C++20)
(C++11)
(C++11)
RandomNumberDistribution
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++14)
(C++14)
(C++11)
(C++11)
(C++17)
(C++14)
(C++20)
(C++20)
(C++23)
(C++23)
(C++23)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
A RandomNumberDistribution is a function object returning random numbers according to a probability density function p(x) or a discrete probability distribution P(xi).
[edit] Requirements
The type D satisfies RandomNumberDistribution if
-  Dsatisfies CopyConstructible
-  Dsatisfies CopyAssignable
Given
-  T, the type named by D::result_type
-  P, the type named by D::param_type, which
- satisfies CopyConstructible
- satisfies CopyAssignable
- satisfies EqualityComparable
-  has a constructor taking identical arguments as each of the constructors of Dthat take arguments corresponding to the distribution parameters
-  has a member function with the identical name, type, and semantics, as every member function of Dthat returns a parameter of the distribution
- declares a member typedef using distribution_type = D;
 
-  d, a value of typeD
-  xandy, (possibly const) values of typeD
-  p, a (possibly const) value of typeP
-  g,g1,g2, lvalues of a type satisfying UniformRandomBitGenerator
-  os, lvalue of a specialization of std::basic_ostream
-  is, lvalue of a specialization of std::basic_istream
The following expressions must be valid and have their specified effects
| Expression | Type | Notes | Complexity | 
|---|---|---|---|
| D::result_type | T | An arithmetic type | Compile-time | 
| D::param_type | P | Compile-time | |
| D() | Creates a distribution indistinguishable from any other default-constructed D | Constant | |
| D(p) | Creates a distribution indistinguishable from Dconstructed directly from the values used to constructp | Same as p's construction | |
| d.reset() | void | Resets the internal state of the distribution. The next call to operator()ondwill not depend on values produced by any engine prior toreset() | Constant | 
| x.param() | P | Returns psuch that D(p).param() == p | No worse than D(p) | 
| d.param(p) | void | Postcondition: d.param() == p | No worse than D(p) | 
| d(g) | T | The sequence of numbers returned by successive invocations of this call with the same gare randomly distributed according to the distribution parametrized byd.param() | Amortized constant number of invocations of g | 
| d(g,p) | T | The sequence of numbers returned by successive invocations of this call with the same gare randomly distributed according to the distribution parametrized byp | Amortized constant number of invocations of g | 
| x.min() | T | The greatest lower bound on the values potentially returned by x’soperator(), as determined by the current values ofx’s parameters | Constant | 
| x.max() | T | The least upper bound on the values potentially returned by x’soperator(), as determined by the current values ofx’s parameters | Constant | 
| x == y | bool | Establishes an equivalence relation. Returns trueif x.param() == y.param() and future infinite sequences of values that would be generated by repeated invocations of x(g1) and y(g2) would be equal as long as g1 == g2 | Constant | 
| x != y | bool | !(x == y) | Constant | 
| os << x | Reference to the type of os | Writes a textual representation of the distribution parameters and internal state to os. The formatting flags and fill character ofosare unchanged | |
| is >> d | Reference to the type of is | Restores the distribution parameters and internal state with data read from is. The formatting flags ofisare unchanged. The data must have been written using a stream with the same locale,CharTandTraitsstream template parameters, otherwise the behavior is undefined. If bad input is encountered, is.setstate(std::ios::failbit) is called, which may throw std::ios_base::failure .dis unchanged in that case | 
[edit] Notes
The parameters of a distribution object may be changed either permanently, by using d.param(p) or just for the duration of a single operator() call, by using d(g,p).
Calls to const member functions of the distribution and os << d do not affect the sequence of numbers produced by repeated d(g).
[edit] Standard library
The following standard library components satisfy RandomNumberDistribution
(C++11)
(class template)
(C++11)
(class template)