20#ifndef RIPPLE_BASICS_RANDOM_H_INCLUDED
21#define RIPPLE_BASICS_RANDOM_H_INCLUDED
23#include <xrpl/beast/utility/instrumentation.h>
24#include <xrpl/beast/xor_shift_engine.h>
35#ifndef __INTELLISENSE__
39 "The Ripple default PRNG engine must return an unsigned integral type.");
44 "The Ripple default PRNG engine return must be at least 64 bits wide.");
50template <
class Engine,
class Result =
typename Engine::result_type>
83 seed = distribution(seeder);
111template <
class Engine,
class Integral>
115rand_int(Engine& engine, Integral min, Integral max)
117 XRPL_ASSERT(max > min,
"ripple::rand_int : max over min inputs");
125template <
class Integral>
132template <
class Engine,
class Integral>
138 return rand_int(engine, Integral(0), max);
141template <
class Integral>
148template <
class Integral,
class Engine>
157template <
class Integral =
int>
167template <
class Byte,
class Engine>
171 detail::is_engine<Engine>::value,
175 return static_cast<Byte
>(rand_int<Engine, std::uint32_t>(
181template <
class Byte = std::u
int8_t>
194template <
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.