randomUUID for runtime / how to generate UUIDs in runtime

via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Apr 17 07:05:25 PDT 2015


Hi!

In the std.uuid PHOBOS library doc I found:

     @trusted UUID randomUUID();
     This function generates a random number based UUID from a 
random number generator.
     CTFE: This function is not supported at compile time.

Than trying a call like
     auto uuid = randomUUID()

results in an error message:
     /usr/include/dmd/phobos/std/random.d(1138,10): Error: static 
variable seeded cannot be read at compile time

My understanding: randomUUID, which is available for runtime 
requires a variable from std.random, which is available only in 
compile time.
Sounds like a mathematical riddle, or?

Why I'm asking: I want to create class instances with an unique 
id as default.
But now that great idea seems to be a death end.

Anyone has an idea how to generate UUIDs in runtime?

Thanks & regards,
Ozan


More information about the Digitalmars-d-learn mailing list