If I seed the random number generator from the C++ standard library with a given number (say seed = 1
), and generate a sequence of random numbers, is this sequence guaranteed to be the same in future versions of the standard?
Does the C++ standard offer guarantees on this?
To be pedantic, nothing is guaranteed about future versions of the standard, including the idea that there may be a future version of the standard.
Now, on to your real question. "The" random number generator in the C++ standard library? There's a lot of them. rand
is not one of them :-)
There are "Random number engines", that generate "random sequences of bits". They include:
linear_congruential_engine
mersenne_twister_engine
subtract_with_carry_engine
The section rand.predef gives required results for specific random number engines. That tells you that they're supposed to be portable. [ Thanks to @HowardHinnant for the reference. ]
The distributions, on the other hand (uniform_int_distribution
, etc) CAN differ from implementation to implementation.