random_shuffle algorithm - are identical results produced without random generator function?

前端 未结 3 1085
青春惊慌失措
青春惊慌失措 2021-01-13 00:07

If a random generator function is not supplied to the random_shuffle algorithm in the standard library, will successive runs of the program produce the same random sequence

3条回答
  •  Happy的楠姐
    2021-01-13 00:44

    25.2.11 just says that the elements are shuffled with uniform distribution. It makes no guarantees as to which RNG is used behind the scenes (unless you pass one in) so you can't rely on any such behavior.

    In order to guarantee the same shuffle outcome you'll need to provide your own RNG that provides those guarantees, but I suspect even then if you update your standard library the random_shuffle algorithm itself could change effects.

提交回复
热议问题