UUID from specific Random seed value?

the juce::Uuid constructor implementation is as follows:

Uuid::Uuid()
{
    Random r;

    for (size_t i = 0; i < sizeof (uuid); ++i)
        uuid[i] = (uint8) (r.nextInt (256));

    // To make it RFC 4122 compliant, need to force a few bits...
    uuid[6] = (uuid[6] & 0x0f) | 0x40;
    uuid[8] = (uuid[8] & 0x3f) | 0x80;
}

Is it possible to add a constructor that allows the user to pass in a specific seed value, so that specific uuids can be consistently recreated?

class JUCE_API  Random  final
{
public:
    //==============================================================================
    /** Creates a Random object based on a seed value.

        For a given seed value, the subsequent numbers generated by this object
        will be predictable, so a good idea is to set this value based
        on the time, e.g.

        new Random (Time::currentTimeMillis())
    */
    explicit Random (int64 seedValue) noexcept;

PR here:

super simple fix: just move that Random to be an optional constructor argument.
Old:

//.h
Uuid(); 
//.cpp
Uuid::Uuid()
{
    Random r;

new:

//.h
Uuid(Random r = Random());
//.cpp
Uuid::Uuid()
{
1 Like