uuid_v4
uuid_v4 copied to clipboard
Is this library able to ensure that UUID_v4 does not conflict?
I used this library to generate uuid but found two cases of uuid conflict today. The two uuids I generated on December 1st conflicted with the two uuids on November 18th and 20th.
Fine, I've had the same uuid generated twice on the same day in 4 months. This probability can no longer meet the requirements of uuid.
I think that depends on the random number generator that you supply. The default isn't necessarily the best, but it does the job most of the time.
Though looking at the source code, it uses random_device, which should be 'true random' https://en.cppreference.com/w/cpp/numeric/random/random_device
When you got that collision, how did you compare? Was it with a hash?
UUIDv4::UUIDGenerator<std::mt19937_64> uuidGenerator;
UUIDv4::UUID uuid = uuidGenerator.getUUID();
std::mt19937_64 is a pseudo random number generator that needs to be sourced with a random number (seed) before it can give you somewhat random numbers.
If you want it to be uuid v4 spec, you need to use std::random_device (which is the default if you don't supply a random engine)