![]() |
Bitcoin ABC 0.32.5
P2P Digital Currency
|
Mixin class that provides helper randomness functions. More...
#include <random.h>
Public Types | |
| typedef uint64_t | result_type |
Public Member Functions | |
| RandomMixin () noexcept=default | |
| RandomMixin (const RandomMixin &)=delete | |
| RandomMixin & | operator= (const RandomMixin &)=delete |
| RandomMixin (RandomMixin &&other) noexcept | |
| RandomMixin & | operator= (RandomMixin &&other) noexcept |
| uint64_t | randbits (int bits) noexcept |
| Generate a random (bits)-bit integer. More... | |
| template<int Bits> | |
| uint64_t | randbits () noexcept |
| Same as above, but with compile-time fixed bits count. More... | |
| uint64_t | randrange (uint64_t range) noexcept |
| Generate a random integer in the range [0..range). More... | |
| void | fillrand (Span< std::byte > span) noexcept |
| Fill a Span with random bytes. More... | |
| template<BasicByte B = uint8_t> | |
| std::vector< B > | randbytes (size_t len) noexcept |
| Generate random bytes. More... | |
| uint32_t | rand32 () noexcept |
| Generate a random 32-bit integer. More... | |
| uint160 | rand160 () noexcept |
| generate a random uint160. More... | |
| uint256 | rand256 () noexcept |
| generate a random uint256. More... | |
| bool | randbool () noexcept |
| Generate a random boolean. More... | |
| template<typename Tp > | |
| Tp | rand_uniform_delay (const Tp &time, typename Tp::duration range) noexcept |
| Return the time point advanced by a uniform random duration. More... | |
| uint64_t | operator() () noexcept |
Static Public Member Functions | |
| static constexpr uint64_t | min () noexcept |
| static constexpr uint64_t | max () noexcept |
Private Member Functions | |
| RandomNumberGenerator auto & | Impl () noexcept |
| Access the underlying generator. More... | |
Private Attributes | |
| uint64_t | bitbuf {0} |
| int | bitbuf_size {0} |
Mixin class that provides helper randomness functions.
Intended to be used through CRTP: https://en.cppreference.com/w/cpp/language/crtp. An RNG class FunkyRNG would derive publicly from RandomMixin<FunkyRNG>. This permits RandomMixin from accessing the derived class's rand64() function, while also allowing the derived class to provide more.
The derived class must satisfy the RandomNumberGenerator concept.
| typedef uint64_t RandomMixin< T >::result_type |
|
defaultnoexcept |
|
delete |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlineprivatenoexcept |
Access the underlying generator.
This also enforces the RandomNumberGenerator concept. We cannot declare that in the template (no template<RandomNumberGenerator T>) because the type isn't fully instantiated yet there.
Definition at line 198 of file random.h.
|
inlinestaticconstexprnoexcept |
|
inlinestaticconstexprnoexcept |
|
inlinenoexcept |
|
delete |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
private |
|
private |