Summary
The standard library provides two random-number-related concepts--generator and distribution. Generators are stateful, must be seeded, and produce unsigned integer outputs (raw bits) via operator()(void). The two important generator types are std::random_device, which produces truly random bits, and std::mt19937, which produces pseudo-random bits.
Distributions are usually stateless, and produce numeric data values via operator()(Gen&). The most important distribution type for most programmers will be std::uniform_int_distribution<int>(a,b), which produces integers in the closed range [a,b]. The standard library provides other distributions, such as std::uniform_real_distribution, std::normal_distribution, and std::discrete_distribution ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access