A type‐erasing, non‐owning reference to any uniform random bit generator.

Synopsis

Declared in <absl/random/bit_gen_ref.h>

class BitGenRef;

Description

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); }

Type Aliases

Name

Description

result_type

The type of the values produced by the referenced bit generator.

Member Functions

Name

Description

BitGenRef [constructor]

Constructors

operator=

Assignment operators

operator()

Invokes the referenced bit generator, returning a generated value.

Static Member Functions

Name

Description

max

Returns the largest possible value from this bit generator.

min

Returns the smallest possible value from this bit generator.

Friends

Name

Description

absl::RandomMockingAccess

Created with MrDocs