Is there a good, portable random number generator available for C++?
By "good", I mean I don't have to include a line of code to seed it, it'll be different with each run of the program, and the pattern won't be apparent.
I know that rand() is available, but issues with it include:
1 - You have to seed it.
2 - It's implementation dependent, and there's no requirement for it to actually have a non-predictable pattern. An implementation could be as simple as:
And it would conform to C99's definition of rand(). (Am I using the right terms here?)
If I were writing this program for just OS X and iOS, I'd use arc4rand()... does anyone have anything comparable I could use in C++?
By "good", I mean I don't have to include a line of code to seed it, it'll be different with each run of the program, and the pattern won't be apparent.
I know that rand() is available, but issues with it include:
1 - You have to seed it.
2 - It's implementation dependent, and there's no requirement for it to actually have a non-predictable pattern. An implementation could be as simple as:
Code:
int rand() {
return 0;
}
And it would conform to C99's definition of rand(). (Am I using the right terms here?)
If I were writing this program for just OS X and iOS, I'd use arc4rand()... does anyone have anything comparable I could use in C++?