Boost logo

Boost :

From: Arkadiy Vertleyb (vertleyb_at_[hidden])
Date: 2007-03-02 15:12:29


"Matthias Schabel" <boost_at_[hidden]> wrote

> I'm not familiar with compile-time GUIDs - where is this discussed?

I don't believe it was discussed -- this is just a thought.

Windows (at least) has a tool (guidgen) that can be used to generate a
unique 128-bit number. This is (or was) used extensively in COM. When you
run the tool, you get something like:

// {0E6AE480-9AE6-4f04-A24E-ABEAA55BB49A}
static const GUID <<name>> =
{ 0xe6ae480, 0x9ae6, 0x4f04, { 0xa2, 0x4e, 0xab, 0xea, 0xa5, 0x5b, 0xb4,
0x9a } };

(you are supposed to paste this into your COM code, and give it a name, to
get a globally-unique 128-bit number)

If we define a template like:

template<int n0, short n1, short n2, char n3, ..., char n10>
struct guid;

then we can use generated text to instantiate this template:

typedef guid<0xe6ae480, 0x9ae6, 0x4f04, 0xa2, 0x4e, 0xab, 0xea, 0xa5, 0x5b,
0xb4, 0x9a> my_guid;

Here we got a 128 bit compile-time universally-unique number.

It's quite easy to define a compile-time less_then operation on such GUIDs.

Regards,
Arkadiy


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk