random#

namespace heph
namespace random#

Functions

std::mt19937_64 createRNG(bool is_deterministic = random_number_generator::IS_DETERMINISTIC)#

Returns a random number generator (RNG) which is preconfigured to be deterministic or not. ‘is_deterministic’ is exposed for unit testing, but shall in general not be set by the caller.

std::pair<std::mt19937_64, std::mt19937_64> createPairOfIdenticalRNGs(bool is_deterministic = random_number_generator::IS_DETERMINISTIC)#

Returns a pair (but not a copy) of identical random number generators (RNG) which are preconfigured to be deterministic, or not. This is useful for testing functions which require two random number generators to be equal. ‘is_deterministic’ is exposed for unit testing, but shall in general not be set by the caller.

namespace random_number_generator#

Variables

static bool IS_DETERMINISTIC = false#
namespace heph
namespace random

Functions

template<BooleanType T>
T random(std::mt19937_64 &mt)#
template<NonBooleanIntegralType T>
T random(std::mt19937_64 &mt, Limits<T> limits = NO_LIMITS<T>)#
template<std::floating_point T>
T random(std::mt19937_64 &mt, Limits<T> limits = NO_LIMITS<T>)#
template<typename T>
T random(std::mt19937_64 &mt)#
template<EnumType T>
T random(std::mt19937_64 &mt)#
template<ChronoTimestampType T>
T random(std::mt19937_64 &mt)#

Create a random timestamp between year 1970 and the year 2100.

template<HasRandomMethod T>
T random(std::mt19937_64 &mt)#
template<typename T>
T random(std::mt19937_64 &mt)
template<typename T>
T random(std::mt19937_64 &mt)
template<typename T>
T random(std::mt19937_64 &mt)

TODO(@graeter) This is a workaround until we have cpp23 and can introduce the generic_random_object_creator

template<StringType T>
T random(std::mt19937_64 &mt, std::optional<size_t> fixed_size = std::nullopt, bool allow_empty = true, bool lower_characters_only = false)#

Generate a random string of characters, including special case characters and numbers.

template<RandomCreatableVector T>
T random(std::mt19937_64 &mt, std::optional<size_t> fixed_size = std::nullopt, bool allow_empty = true)#

Fill a vector with randomly generated values of type T.

template<RandomCreatableArray T>
T random(std::mt19937_64 &mt)#

Fill a vector with randomly generated values of type T.

template<RandomCreatableUnorderedMap T>
T random(std::mt19937_64 &mt, std::optional<size_t> fixed_size = std::nullopt, bool allow_empty = true)#

Fill a vector with randomly generated values of type T.

template<RandomCreatableVectorOfVectors T>
T random(std::mt19937_64 &mt, std::optional<size_t> fixed_size = std::nullopt, bool allow_empty = true)#

Fill a vector with randomly generated values of type T.

template<RandomCreatableVectorOfArrays T>
T random(std::mt19937_64 &mt, std::optional<size_t> fixed_size = std::nullopt, bool allow_empty = true)#

Fill a vector with randomly generated values of type T.

template<NumericType T>
struct Limits#

Public Members

T min#
T max#

Variables

template<NumericType T> Limits< T > NO_LIMITS   = { .min = std::numeric_limits<T>::min(), .max = std::numeric_limits<T>::max() }