[#absl-BitGenRef] = xref:absl.adoc[absl]::BitGenRef :relfileprefix: ../ :mrdocs: A type‐erasing, non‐owning reference to any uniform random bit generator. == Synopsis Declared in `<absl/random/bit_gen_ref.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- 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 [cols="1,4"] |=== | Name| Description | xref:absl/BitGenRef/result_type.adoc[`result_type`] | The type of the values produced by the referenced bit generator. |=== == Member Functions [cols="1,4"] |=== | Name| Description | xref:absl/BitGenRef/2constructor-0f.adoc[`BitGenRef`] [.small]#[constructor]# | Constructors | xref:absl/BitGenRef/operator_assign-04.adoc[`operator=`] | Assignment operators | xref:absl/BitGenRef/operator_call.adoc[`operator()`] | Invokes the referenced bit generator, returning a generated value. |=== == Static Member Functions [cols="1,4"] |=== | Name| Description | xref:absl/BitGenRef/max.adoc[`max`] | Returns the largest possible value from this bit generator. | xref:absl/BitGenRef/min.adoc[`min`] | Returns the smallest possible value from this bit generator. |=== == Friends [cols="1,4"] |=== | Name| Description | `absl::RandomMockingAccess` | |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#