Usefulness of `rand()` – or who should call `srand()`?

Use the new <random> header instead. It allows for multiple engine instances, using different algorithms and more importantly for you, independent seeds.

[edit]
To answer the “useful” part, rand generates random numbers. That’s what it’s good for. If you need fine-grained control, including reproducibility, you should not only have a known seed but a known algorithm. srand at best gives you a fixed seed, so that’s not a complete solution anyway.

Leave a Comment