24 Jan
2011
24 Jan
'11
9:11 p.m.
AMDG On 1/24/2011 12:57 PM, Lasse Kliemann wrote:
I use /dev/urandom for this, like so (code fragments):
FILE *dev_urandom; uint32_t seed; if((dev_urandom = fopen("/dev/urandom", "r")) == NULL) throw /* error */ if(fread(&seed, sizeof(seed), 1, dev_urandom) == 0) throw /* error */ if(fclose(dev_urandom) != 0) throw /* error */ boost::mt19937 gen(seed);
But maybe there are even better ways.
boost::random_device seed_gen; boost::mt19937 gen(seed_gen()); should have the same effect and is more portable. In Christ, Steven Watanabe