Boost logo

Boost Users :

Subject: Re: [Boost-users] time variant uuid
From: Nat Linden (nat_at_[hidden])
Date: 2012-05-10 08:17:05


On Wed, May 9, 2012 at 9:40 PM, Victor Whiskey Yankee
<victor.whiskey.yankee_at_[hidden]> wrote:

> 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);
>
> If this can be done, then is there a way to extract the date+time from it?

Are you sure you want a UUID? Wouldn't a string such as:

2012-05-10T08.07.33-your-other-data

better suit this use case?

I don't know much about the details of UUID construction, but my
belief is that a typical UUID is a hash of various input elements. A
typical hash has a couple properties that would make it unsuitable for
your requirements:

* Unpredictability. The inputs are munged in a way designed to be hard
to guess. Most users explicitly do not want hash(data1), hash(data2)
to track any assertions one might make about data1, data2.
* Irreversibility. In many hash use cases, users explicitly do not
want anyone to be able to extract data from hash(data).

Of course I may be completely wrong about Boost.Uuid. I could study
the source... but then so could you. ;-)


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