Boost logo

Boost :

From: Matthias Schabel (boost_at_[hidden])
Date: 2007-02-28 16:08:50


For various reasons, it would be really nice to be able to generate
a series of unique ordinal values (say integers, but really anything
that is easily less_than_comparable) at compile time. A concrete
example :

struct system1 : ordinal<0> { };
struct system2 : ordinal<1> { };

etc...

Now, if these tags can be defined in user code in various places,
it can be difficult to ensure that there is no duplication of the
ordinal
values. What I want is something like this:

struct system1 : ordinal<get_next_system_ordinal()> { };
struct system2 : ordinal<get_next_system_ordinal()> { };

where I don't really care what the specific order is, just that the
ordinal values are unique... Anyone have a bright idea on how to
accomplish this? Preprocessor?

Matthias


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