I have a set of classes that derive from the same base classes that roughly look like this:
class IClass
{
public:
virtual int64_t getIdentifier() const = 0;
};
template<int64_t ID>
class Base : public IClass
{
public:
static const int64_t s_identifier = ID;
virtual int64_t getIdentifier() const { return s_identifier; }
};
I want to use the static s_identifier
to identify a set of derived classes (I know there is the typeid operator but I would like to find another solution).
One derived class could for example look like this:
class Derived : public Base<0x630aea1e>
{
};
I'm searching for a way to get warned if there are two derived classes with the same identifier (to avoid copy&paste errors or simply because someone puts two times 0x12345678
as ID). I think it must be done at compile time but I currently cannot think of a way how to do this, maybe someone can help me.