random: add parameter free uniform for integral types

This commit is contained in:
Danny Robson 2022-05-10 12:48:52 +10:00
parent 234adca06f
commit ef24f0bfda

View File

@ -189,6 +189,21 @@ namespace cruft::random {
}
///------------------------------------------------------------------------
/// Return a uniformly random chosen value over integral values in the type
template <typename T, typename GeneratorT>
requires (std::is_integral_v<T> and UniformRandomBitGenerator<std::remove_cvref_t<GeneratorT>>)
T
uniform (GeneratorT &&gen)
{
return uniform<T> (
std::numeric_limits<T>::min (),
std::numeric_limits<T>::max (),
std::forward<GeneratorT> (gen)
);
}
///------------------------------------------------------------------------
/// Returns a uniformly random initialised coordinate type by value.
template <