Like my posting about cloning this posting about unique identifier values is in preparation for discussing the cppx library’s exception translation support. In short the aspect discussed here is how to let the calling code choose an id for a set of installed translators, so that it can remove them all in one operation (specifying that id). And the simplest id you have in C++ is a type with external linkage. You can obtain a unique-wrt.-comparisions id for a class from the typeid
operator. The only problem is that that id, of type std::type_info
, is not copyable and not generally comparable, so it can’t be used directly as a key in a std::map
, say, and the standard fails to guarantee that you will always obtain the same std::type_info
instance for the same type, so it’s a bit risky to use a pointer to that instance…