6#include <userver/utils/assert.hpp>
12USERVER_NAMESPACE_BEGIN
20 using result_type = uint32_t;
22 virtual ~RandomBase() =
default;
24 virtual result_type operator()() = 0;
26 static constexpr result_type min() {
return std::mt19937::min(); }
27 static constexpr result_type max() {
return std::mt19937::max(); }
51 "attempt to get a random value in an incorrect range");
52 if constexpr (std::is_floating_point_v<T>) {
53 return std::uniform_real_distribution<T>{from_inclusive,
58 return std::uniform_int_distribution<std::common_type_t<T,
unsigned short>>{
59 from_inclusive, to_exclusive - 1}(DefaultRandom());
67 return RandRange(T{0}, to_exclusive);