13#include <userver/compiler/thread_local.hpp> 
   14#include <userver/utils/assert.hpp> 
   16USERVER_NAMESPACE_BEGIN
 
   24  using result_type = uint32_t;
 
   26  virtual ~RandomBase() = 
default;
 
   28  virtual result_type operator()() = 0;
 
   30  static constexpr result_type min() { 
return std::mt19937::min(); }
 
   31  static constexpr result_type max() { 
return std::mt19937::max(); }
 
   36std::seed_seq MakeSeedSeq();
 
   42  result_type operator()() 
override { 
return gen_(); }
 
   48compiler::ThreadLocalScope<RandomImpl> UseLocalRandomImpl();
 
   76template <
typename Func>
 
   78  auto random = impl::UseLocalRandomImpl();
 
   79  return std::forward<Func>(func)(
static_cast<RandomBase&>(*random));
 
   88             "attempt to get a random value in an incorrect range");
 
   89  if constexpr (std::is_floating_point_v<T>) {
 
   90    return utils::WithDefaultRandom(
 
   91        std::uniform_real_distribution<T>{from_inclusive, to_exclusive});
 
   95    return utils::WithDefaultRandom(
 
   96        std::uniform_int_distribution<std::common_type_t<T, 
unsigned short>>{
 
   97            from_inclusive, to_exclusive - 1});
 
  105  return RandRange(T{0}, to_exclusive);
 
  111template <
typename Container>
 
  113  utils::WithDefaultRandom([&container](
RandomBase& rng) {
 
  114    std::shuffle(std::begin(container), std::end(container), rng);