From d67a990de3381be247321bb0f9ef6f6dfcbe0087 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Thu, 21 Sep 2017 15:58:26 +1000 Subject: [PATCH] random: add uniform integer generator for whole range --- random.hpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/random.hpp b/random.hpp index 9c5f65ea..235a592d 100644 --- a/random.hpp +++ b/random.hpp @@ -18,6 +18,7 @@ #define CRUFT_UTIL_RANDOM_HPP #include +#include namespace util::random { @@ -52,6 +53,18 @@ namespace util::random { } + /////////////////////////////////////////////////////////////////////////// + template + std::enable_if_t,T> + uniform (void) + { + return uniform ( + std::numeric_limits::min (), + std::numeric_limits::max () + ); + } + + /////////////////////////////////////////////////////////////////////////// /// choose a value at random from an array template