Fix random::uniform() for integral types

This commit is contained in:
Nikita Lisitsa 2023-03-20 13:04:53 +03:00
parent d68242d59d
commit d824159c2f

View file

@ -34,10 +34,14 @@ namespace psemek::random
{
return uniform<char>(rng, 0, 1) == 1;
}
else
else if constexpr (std::is_floating_point_v<T>)
{
return uniform<T>(rng, T{0}, T{1});
}
else if constexpr (std::is_integral_v<T>)
{
return uniform<T>(rng, std::numeric_limits<T>::min(), std::numeric_limits<T>::max());
}
}
template <typename T, std::size_t N, typename RNG>