Check out RandomLib which is a C ++ random number library with good seed support. In particular
Random r; r.Reseed();
forces r to sow with a vector of numbers (from calling to RandomSeed :: SeedVector ()), which is almost certainly unique. This includes time, microseconds, pid, hostid, year.
Less optimally, you can also sow RandomSeed :: SeedWord (), which reads from / dev / urandom, if possible. However, you usually get an initial collision after 2 ^ 16 working with one 32-bit word as your seed. Thus, if your application starts many times, you better use the larger seed space offered by the vector.
Of course, this assumes that you are using a random number generator that can use vector seed. RandomLib offers MT19937 and SFMT19937 that use seeds for vectors.
source share