A type-erasing, non-owning reference to any uniform random bit generator.
Declared in <absl/random/bit_gen_ref.h>
class BitGenRef;
absl::BitGenRef provides a generator-agnostic non-owning "reference" interface for use in place of any specific uniform random bit generator (URBG). This class may be used for both Abseil (e.g. absl::BitGen, absl::InsecureBitGen) and Standard library (e.g std::mt19937, std::minstd_rand) bit generators.
Like other reference classes, absl::BitGenRef does not own the underlying bit generator, and the underlying instance must outlive the absl::BitGenRef.
absl::BitGenRef is particularly useful when used with an absl::MockingBitGen to test specific paths in functions which use random values.
Example: void TakesBitGenRef(absl::BitGenRef gen) { int x = absl::Uniform<int>(gen, 0, 1000); }
| Name | Description |
|---|---|
result_type | The type of the values produced by the referenced bit generator. |
| Name | Description |
|---|---|
BitGenRef [constructor] | Constructors |
operator= | Assignment operators |
operator() | Invokes the referenced bit generator, returning a generated value. |
| Name | Description |
|---|---|
max | Returns the largest possible value from this bit generator. |
min | Returns the smallest possible value from this bit generator. |
| Name | Description |
|---|---|
absl::RandomMockingAccess |