std::random_shuffle
is (effectively) replaced by std::shuffle
. You do need to pass a third parameter (a random number generator), but in exchange for that you get substantially better definition and (typically) behavior.
std::random_shuffle
was fairly poorly defined. It typically used rand()
to generate the random numbers, but nothing said whether (and if so how) it called srand
, so you couldn't depend (for one example) in rand
being seeded how you wanted (and if you seeded it, you couldn't depend on that being put to use). If memory serves, there was also some confusing (and somewhat self-contradictory) language that could be interpreted as saying that random_shuffle
couldn't use rand
at all, and/or that it couldn't seed it with srand
. Even at best, many implementations of rand()
were quite poor, so even at very best you couldn't depend on useful results.
Bottom line: random_shuffle
is no loss. Use std::shuffle
instead, and your code will be much better for it.