From d824159c2fd0310ad3e44a26d7afbb0d039f32aa Mon Sep 17 00:00:00 2001 From: lisyarus Date: Mon, 20 Mar 2023 13:04:53 +0300 Subject: [PATCH] Fix random::uniform() for integral types --- libs/random/include/psemek/random/uniform.hpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libs/random/include/psemek/random/uniform.hpp b/libs/random/include/psemek/random/uniform.hpp index 465069ac..31b27718 100644 --- a/libs/random/include/psemek/random/uniform.hpp +++ b/libs/random/include/psemek/random/uniform.hpp @@ -34,10 +34,14 @@ namespace psemek::random { return uniform(rng, 0, 1) == 1; } - else + else if constexpr (std::is_floating_point_v) { return uniform(rng, T{0}, T{1}); } + else if constexpr (std::is_integral_v) + { + return uniform(rng, std::numeric_limits::min(), std::numeric_limits::max()); + } } template