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); I don't see how to replace random_generator() with a time-based variant, if that even makes sense. If this can be done, then is there a way to extract the date+time from it? Thanks, Vic
On Wed, May 9, 2012 at 9:40 PM, Victor Whiskey Yankee
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. ;-)
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
participants (3)
-
Andy Tompkins
-
Nat Linden
-
Victor Whiskey Yankee