[#absl-InsecureBitGen] = xref:absl.adoc[absl]::InsecureBitGen :relfileprefix: ../ :mrdocs: An efficient random bit generator for performance‐sensitive use cases. == Synopsis Declared in `<absl/random/random.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- class InsecureBitGen; ---- == Description `absl::InsecureBitGen` is recommended only for performance‐sensitive use cases where `absl::BitGen` is not satisfactory when compute‐bounded by bit generation costs. Example: // Create an absl::InsecureBitGen absl::InsecureBitGen gen; for (size_t i = 0; i < 1000000; i++) { // Generate a bunch of random values from some complex distribution auto my_rnd = some_distribution(gen, 1, 1000); } Like `absl::BitGen`, `absl::InsecureBitGen` is seeded by default with non‐deterministic data to produce different sequences of random values across different instances, including different binary invocations. (This behavior is different than the standard library bit generators, which use golden values as their seeds.) `absl::InsecureBitGen` may be constructed with an optional seed sequence type, conforming to [rand.req.seed_seq], which will be mixed with additional non‐deterministic data, as detailed in the `absl::BitGen` comment. `absl::InsecureBitGen` meets the requirements of the Uniform Random Bit Generator (URBG) concept as per the C++17 standard [rand.req.urng]though its implementation differs slightly with [rand.req.eng]. Like its standard library equivalents (e.g. `std::mersenne_twister_engine`) `absl::InsecureBitGen` is not cryptographically secure. Prefer `absl::BitGen` over `absl::InsecureBitGen` as the general type is often fast enough for the vast majority of applications. However, it is reasonable to use `absl::InsecureBitGen` in tests or when using a URBG in small isolated tasks such as in `std::shuffle`. This type is thread‐compatible, but not thread‐safe. == Type Aliases [cols="1,4"] |=== | Name| Description | xref:absl/InsecureBitGen/result_type.adoc[`result_type`] | The type of the values produced by this bit generator. |=== == Using Declarations [cols="1,4"] |=== | Name| Description | xref:absl/InsecureBitGen/InsecureBitGen.adoc[`InsecureBitGen`] | Inherits the base constructors. | xref:absl/InsecureBitGen/discard.adoc[`discard`] | Advances the internal state of this bit generator. | xref:absl/InsecureBitGen/max.adoc[`max`] | Returns the largest possible value from this bit generator. | xref:absl/InsecureBitGen/min.adoc[`min`] | Returns the smallest possible value from this bit generator. | xref:absl/InsecureBitGen/operator!=.adoc[`operator!=`] | Compares two bit generators for inequality. | xref:absl/InsecureBitGen/operator().adoc[`operator()`] | Invokes the URBG, returning a generated value. | xref:absl/InsecureBitGen/operator=.adoc[`operator=`] | Inherits the base assignment operators. | xref:absl/InsecureBitGen/operator==.adoc[`operator==`] | Compares two bit generators for equality. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#