random: add uniform integer generator for whole range
This commit is contained in:
parent
b04f0b0c9e
commit
d67a990de3
13
random.hpp
13
random.hpp
@ -18,6 +18,7 @@
|
||||
#define CRUFT_UTIL_RANDOM_HPP
|
||||
|
||||
#include <random>
|
||||
#include <limits>
|
||||
|
||||
|
||||
namespace util::random {
|
||||
@ -52,6 +53,18 @@ namespace util::random {
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <typename T>
|
||||
std::enable_if_t<std::is_integral_v<T>,T>
|
||||
uniform (void)
|
||||
{
|
||||
return uniform (
|
||||
std::numeric_limits<T>::min (),
|
||||
std::numeric_limits<T>::max ()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
/// choose a value at random from an array
|
||||
template <typename T, size_t N>
|
||||
|
Loading…
Reference in New Issue
Block a user