Given the following:
template
class A
{
public:
static const unsigned int ID = ?;
};
I want ID to generate a unique c
What I usually use is this:
template
void type_id(){}
using type_id_t = void(*)();
Since every instantiation of the function has it's own address, you can use that address to identify types:
// Work at compile time
constexpr type_id_t int_id = type_id;
// Work at runtime too
std::map types;
types[type_id] = 4;
types[type_id] = "values"s
// Find values
auto it = types.find(type_id);
if (it != types.end()) {
// Found it!
}