Class holding a rule to create values with predefined properties. More...
Public Member Functions | |
template<typename U > | |
Distribution (U constant) | |
Construct from constant. More... | |
template<typename Fn > | |
Distribution (Fn function) | |
Construct from distribution function. More... | |
T | operator() () const |
Returns a value according to the distribution. | |
Class holding a rule to create values with predefined properties.
Contains a callback that returns values on demand. These can be constant (always the same value), according to a random distribution, or be read from a value elsewhere in your code. Generally, the callback can be any function, member function or functor returning a value of type T and taking no arguments.
thor::Distribution can be linked to random distributions of the standard library:
Construct from constant.
constant | Constant value convertible to T. The distribution's operator() will always return this value. |
Construct from distribution function.
function | Callable convertible to std::function<T()>. Every time the operator() of this distribution is invoked, it returns the return value of the specified function. |