"Victor Bazarov" <v.********@comAcast.net> wrote in message
news:O9****************@newsread1.dllstx09.us.to.v erio.net...
Christopher Brian Colohan wrote: This has probably been done a zillion times before, but it is new to
me (and some of the folks I work with), and also quite useful.
Let me know if there are obvious improvements that I have missed. :-)
http://www.colohan.com/docs/unique_integers.html
It would be nice not to have the number stated as the template argument
when declaring typedefs. I am not sure it's possible, but I suspect
that it is.
It can almost be done with CRTP:
struct set_num_t : unique_int<set_num_t> { };
The trouble is you lose the constructor taking an unsigned int and the private
constructor taking a bool. If you don't mind macros, you could do
#define UNIQUE_INT(name) \
struct name : unique_int<name> { \
private: name(bool); \
public: name(unsigned v = 0u) : unique_int<name>(v) { }\
}; \
/**/
UNIQUE_INT(set_num_t)
UNIQUE_INT(entry_num_t)
UNIQUE_INT(lru_entry_t)
Jonathan