Add random::uniform helper function

This commit is contained in:
Nikita Lisitsa 2021-03-07 11:54:11 +03:00
parent 9d29e3a656
commit e87c4508fc

View file

@ -11,4 +11,16 @@ namespace psemek::random
template <typename T>
using uniform_distribution = std::conditional_t<std::is_floating_point_v<T>, uniform_real_distribution<T>, uniform_int_distribution<T>>;
template <typename T, typename RNG>
T uniform(RNG && rng, geom::interval<T> const & range)
{
return uniform_distribution<T>{range}(rng);
}
template <typename T, typename RNG>
T uniform(RNG && rng, T min, T max)
{
return uniform<T>(rng, {min, max});
}
}