1#ifndef XRPL_BASICS_RANDOM_H_INCLUDED
2#define XRPL_BASICS_RANDOM_H_INCLUDED
4#include <xrpl/beast/utility/instrumentation.h>
5#include <xrpl/beast/xor_shift_engine.h>
16#ifndef __INTELLISENSE__
20 "The Ripple default PRNG engine must return an unsigned integral type.");
25 "The Ripple default PRNG engine return must be at least 64 bits wide.");
31template <
class Engine,
class Result =
typename Engine::result_type>
64 seed = distribution(seeder);
92template <
class Engine,
class Integral>
96rand_int(Engine& engine, Integral min, Integral max)
98 XRPL_ASSERT(max > min,
"ripple::rand_int : max over min inputs");
106template <
class Integral>
113template <
class Engine,
class Integral>
119 return rand_int(engine, Integral(0), max);
122template <
class Integral>
129template <
class Integral,
class Engine>
138template <
class Integral =
int>
148template <
class Byte,
class Engine>
152 detail::is_engine<Engine>::value,
156 return static_cast<Byte
>(rand_int<Engine, std::uint32_t>(
162template <
class Byte = std::u
int8_t>
175template <
class Engine>
detail::xor_shift_engine<> xor_shift_engine
XOR-shift Generator.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::enable_if_t<(std::is_same< Byte, unsigned char >::value||std::is_same< Byte, std::uint8_t >::value), Byte > rand_byte()
std::enable_if_t< std::is_integral< Integral >::value, Integral > rand_int()
beast::xor_shift_engine & default_prng()
Return the default random engine.