List of all members | Public Member Functions
thor::Distribution< T > Class Template Reference

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...
operator() () const
 Returns a value according to the distribution.

Detailed Description

template<typename T>
class thor::Distribution< T >

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:

std::mt19937 engine;
std::uniform_int_distribution<int> distr(0, 7);
auto randomizer = std::bind(distr, engine);
thor::Distribution<int> thorDistr(randomizer);

Constructor & Destructor Documentation

template<typename T>
template<typename U >
thor::Distribution< T >::Distribution ( constant)

Construct from constant.

constantConstant value convertible to T. The distribution's operator() will always return this value.
template<typename T>
template<typename Fn >
thor::Distribution< T >::Distribution ( Fn  function)

Construct from distribution function.

functionCallable convertible to std::function<T()>. Every time the operator() of this distribution is invoked, it returns the return value of the specified function.

The documentation for this class was generated from the following file: