In C++11 one can generate numbers with the use of std::random_device
with or without a pseudo random number generator like mt19937.
What will be the difference using this in this exemplar code:
#include <random>
#include <iostream>
int main() {
std::random_device rd;
std::mt19937 mt(rd());
std::uniform_real_distribution<double> dist(1, 10);
for (int i=0; i<16; ++i)
std::cout << dist(rd) << "\t" << dist(mt) << "\n";
}
std::random_device
is supposed to get you a seed for engines likemt19937
. The quality of successive numbers produced is completely undefined and may easily be insufficient for practical purposes (such as cryptography), so relying on that is out of question.Apart from that,
mt19937
will give you the same sequence when given the same seed. Arandom_device
s values can be only influenced by the string given to its constructor... which implies implementation-defined behavior.