
2 Sep
2011
2 Sep
'11
5:33 p.m.
On Fri, Sep 2, 2011 at 9:06 AM, Nigel Stewart <nigels.com@gmail.com> wrote: [...]
Please don't do this!
unsigned int next_id() { static unsigned int previous_id = 0; //0 is not assigned to a type ++previous_id; return previous_id; }
Indeed, runtime allocation of unique identifiers is problematic. But perhaps there is some kind of compile-time trick, apart from manually assigning enums in some central header. And ideally, portable across compilers so that foo.dll and bar.dll would be consistant without being build by the same vendor, or toolchains.
For the "compile-time trick", I'd guess the closest thing would be what Boost.TypeOf does. And I don't see that being practical for this application. - Jeff