jeudi 26 août 2021

Equivalent way of srand() and rand() using post-c++11 std library

I have old code that uses predates c++11 and it uses rand() for generating random ints.

However, there is shortcoming in rand(): you can't save and then restore the state of the random device; since there is not an object I can save, nor can I extract the state.

Therefore, I want to refactor to use c++11's solution <random>.

However, I do not want a behaviour change - I hope to get exactly the sequence rand() gives me but with <random>.

Do you guys know whether this is achievable?




Aucun commentaire:

Enregistrer un commentaire