random: add 0-to-n uniform convenience function

This commit is contained in:
Danny Robson 2019-05-13 16:15:24 +10:00
parent 831b02c907
commit b5fdedfe5e

View File

@ -88,6 +88,19 @@ namespace cruft::random {
}
///------------------------------------------------------------------------
/// Return a value uniformly chosen between 0 and the given value.
///
/// Interval bounds are treated as per the standard Generator
/// implementations; ie, inclusive for integers, exclusive upper for reals.
template <typename T>
decltype(auto)
uniform (T hi)
{
return uniform<T> (T{0}, hi);
}
///------------------------------------------------------------------------
/// Return a uniformly random value chosen on the interval [0,1)
template <