random: add 0-to-n uniform convenience function
This commit is contained in:
parent
831b02c907
commit
b5fdedfe5e
13
random.hpp
13
random.hpp
@ -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)
|
/// Return a uniformly random value chosen on the interval [0,1)
|
||||||
template <
|
template <
|
||||||
|
Loading…
Reference in New Issue
Block a user