I need to generate large number of UUIDs. If I don't make rg
static, it would take lot of time in default constructing it every time. Is there anything wrong if I make it static, would it hurt uniqueness of uuids in anyway?
Is there any better way to do it?
using namespace boost::uuids;
uuid generateUUID() {
static random_generator rg; // here
return rg();
}
void someFunction() {
for (int i = 0; i < 1000000; ++i) {
uuid id = generateUUID();
// use id
}
}
No, there is no problem with that.