std::random_device is a C++ standard-library generator that supplies nondeterministic random values when the implementation supports them. Its practical role is usually seeding a separate random-number engine rather than producing every value directly. section 3.2.1
Seed an engine
std::random_device rd;\nstd::mt19937 engine(rd());\n\nThe device supplies an initial seed; the engine then produces the sequence used with a distribution such as std::uniform_int_distribution<int>. section 3.2.1
Use the interface with these practical cautions:
- Check several returned values: some older implementations always returned 0, and an implementation may repeat a sequence. section 3.2.1
- Prefer it as a seed source when repeated calls could begin producing the same values. section 3.2.1
