[#absl-BitGen]
= xref:absl.adoc[absl]::BitGen
:relfileprefix: ../
:mrdocs:

A general&hyphen;purpose random bit generator for the Abseil random library&period;

== Synopsis

Declared in `&lt;absl&sol;random&sol;random&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
class BitGen;
----

== Description

Typically, you use a bit generator in combination with a distribution to provide random values&period;

Example&colon;

&sol;&sol; Create an absl&colon;&colon;BitGen&period; There is no need to seed this bit generator&period; absl&colon;&colon;BitGen gen&semi;

&sol;&sol; Generate an integer value in the closed interval &lsqb;1,6&rsqb; int die&lowbar;roll &equals; absl&colon;&colon;uniform&lowbar;int&lowbar;distribution&lt;int&gt;(1, 6)(gen)&semi;

`absl&colon;&colon;BitGen` is seeded by default with non&hyphen;deterministic data to produce different sequences of random values across different instances, including different binary invocations&period; This behavior is different than the standard library bit generators, which use golden values as their seeds&period; Default construction intentionally provides no stability guarantees, to avoid accidental dependence on such a property&period;

`absl&colon;&colon;BitGen` may be constructed with an optional seed sequence type, conforming to &lsqb;rand&period;req&period;seed&lowbar;seq&rsqb;, which will be mixed with additional non&hyphen;deterministic data as detailed below&period;

Example&colon;

&sol;&sol; Create an absl&colon;&colon;BitGen using an std&colon;&colon;seed&lowbar;seq seed sequence std&colon;&colon;seed&lowbar;seq seq&lcub;1,2,3&rcub;&semi; absl&colon;&colon;BitGen gen&lowbar;with&lowbar;seed(seq)&semi;

&sol;&sol; Generate an integer value in the closed interval &lsqb;1,6&rsqb; int die&lowbar;roll2 &equals; absl&colon;&colon;uniform&lowbar;int&lowbar;distribution&lt;int&gt;(1, 6)(gen&lowbar;with&lowbar;seed)&semi;

Constructing two `absl&colon;&colon;BitGen`s with the same seed sequence in the same process will produce the same sequence of variates, but need not do so across multiple processes even if they&apos;re executing the same binary&period;

`absl&colon;&colon;BitGen` meets the requirements of the Uniform Random Bit Generator (URBG) concept as per the C&plus;&plus;17 standard &lsqb;rand&period;req&period;urng&rsqb;though differs slightly with &lsqb;rand&period;req&period;eng&rsqb;&period; Like its standard library equivalents (e&period;g&period; `std&colon;&colon;mersenne&lowbar;twister&lowbar;engine`) `absl&colon;&colon;BitGen` is not cryptographically secure&period;

This type has been optimized to perform better than Mersenne Twister (https&colon;&sol;&sol;en&period;wikipedia&period;org&sol;wiki&sol;Mersenne&lowbar;Twister) and many other complex URBG types on modern x86, ARM, and PPC architectures&period;

This type is thread&hyphen;compatible, but not thread&hyphen;safe&period;

== Type Aliases

[cols="1,4"]
|===
| Name| Description
| xref:absl/BitGen/result_type.adoc[`result&lowbar;type`] 
| The type of the values produced by this bit generator&period;
|===


== Using Declarations

[cols="1,4"]
|===
| Name| Description
| xref:absl/BitGen/BitGen.adoc[`BitGen`] 
| Inherits the base constructors&period;
| xref:absl/BitGen/discard.adoc[`discard`] 
| Advances the internal state of this bit generator&period;
| xref:absl/BitGen/max.adoc[`max`] 
| Returns the largest possible value from this bit generator&period;
| xref:absl/BitGen/min.adoc[`min`] 
| Returns the smallest possible value from this bit generator&period;
| xref:absl/BitGen/operator!=.adoc[`operator!&equals;`] 
| Compares two bit generators for inequality&period;
| xref:absl/BitGen/operator().adoc[`operator()`] 
| Invokes the URBG, returning a generated value&period;
| xref:absl/BitGen/operator=.adoc[`operator&equals;`] 
| Inherits the base assignment operators&period;
| xref:absl/BitGen/operator==.adoc[`operator&equals;&equals;`] 
| Compares two bit generators for equality&period;
|===



[.small]#Created with https://www.mrdocs.com[MrDocs]#
