Boost logo

Boost Users :

Subject: Re: [Boost-users] time variant uuid
From: Andy Tompkins (atompkins_at_[hidden])
Date: 2012-05-10 13:12:43


On Wed, May 9, 2012, at 08:40 PM, Victor Whiskey Yankee wrote:
> Hello List,
>
> How can I create uuids so that the first one compares less than the
> next one.. something like this:
>
> boost::uuids::t1 = boost::uuids::random_generator()();
> boost::uuids::t2 = boost::uuids::random_generator()();
> BOOST_REQUIRE(t1 < t2);

This is not guaranteed to be true, t1 may be greater than t2. It really
is random data used to create the uuid in this case.

> I don't see how to replace random_generator() with a time-based
> variant, if that even makes sense.

Sadly, I have not yet implemented a time-based generator for uuids. I
plan to create a few platform specific generators that wrap OS calls
that would do this.

> If this can be done, then is there a way to extract the date+time
> from it?

If is is a time-based uuid, then the date and time can be extracted, but
not from a random-based, or name-based (uses a hash).

> Thanks, Vic

Regards,
Andy Tompkins


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net