I wonder if some means of template metaprogramming allows you to assign unique integral identifiers for different types, that is, something like this:
class Type; enum { id = identifier<Type>() }; static_assert(id == identifier<Type>(), "...");
The tough part, I think, is that the identifier must remain unchanged in one compilation (which does not necessarily match the compilation unit). But of course, since I donβt know the technique or, if at all possible, I really donβt know which is the hardest part.
Edit: How in one compilation unit?
source share