Random#

Random number generation facilities.

Info

To use declarations from this page, include the <essence/random.hpp> header.

static std::random_device random::device#

The systems’ default random device.

static thread_local std::mt19937 twister = std::mt19937{device()}#

A thread local Mersenne Twister pseudorandom number genrator.

static thread_local std::philox4x32 philox = std::philox4x32{device()}#

A thread local philox counter-based pseudorandom number generator.

static thread_local std::default_random_engine def = std::default_random_engine{device()}#

A thread local (implementation defined) pseudorandom number generator.

template<typename T = i32>
T rng(T min, T max) noexcept#

Generate a random number between min and max. T must be an integral or floating point type.

Uses the twister generator.

template<typename T = i32>
T rng(T max) noexcept#

Generate a random number between 0 and max. T must be an integral or floating point type.

Uses the twister generator.

using namespace essence;

// a random 32-bit unsigned integer
auto rui = rng<u32>(20, 100);

// a random 64-bit floating point number
auto rfp = rng<f64>(100.0);