userver: userver/utils/rand.hpp File Reference
Loading...
Searching...
No Matches
rand.hpp File Reference

Detailed Description

Random number generators.

Definition in file rand.hpp.

Go to the source code of this file.

#include <algorithm>
#include <cstdint>
#include <limits>
#include <random>
#include <utility>
#include <userver/compiler/thread_local.hpp>
#include <userver/utils/assert.hpp>

Classes

class  utils::RandomBase
 Virtualized standard UniformRandomBitGenerator concept, for use with random number distributions. More...
 

Namespaces

namespace  utils
 Utilities.
 

Functions

template<typename Func >
decltype(autoutils::WithDefaultRandom (Func &&func)
 Calls func with a thread-local UniformRandomBitGenerator (specifically of type utils::RandomBase).
 
template<typename T >
utils::RandRange (T from_inclusive, T to_exclusive)
 Generates a random number in range [from, to)
 
template<typename T >
utils::RandRange (T to_exclusive)
 Generates a random number in range [0, to)
 
template<typename Container >
void utils::Shuffle (Container &container)
 Shuffles the elements within the container.
 
std::uint32_t utils::Rand ()
 Generate a random number in the whole uint32_t range.