
Andy wrote:
I agree that the create function needs improvement. It suffers from threading problems (because of static variables) and from a hard coded random number generator (also a hard coded seed).
My solution is to create a generator class, as follows:
// maybe a better name // maybe a different default random number generator template <typename UniformRandomNumberGenerator = boost::mt19937> class random_guid_generator : boost::noncopyable
[...]
random_guid_generator<> guid_gen; guid g = guid_gen.create();
Why not just add an Engine & e parameter to guid::create? For the default seed, you might want to look into combining several sources of entropy (unpredictable values) such as - time(0) - clock() - the values of an unsigned char[] array that is allocated on the stack and not initialized - the addresses of some variables or functions - the address of a newly allocated object - anything else that you can come up with