I cannot think of any possible solution at compile time using C ++.
I can think of a possible solution at startup (initializing the library), but it will be limited.
class A: public Base<A,1> {};
We have Base register the correspondence between id 1 and class typeid(A) during library initialization. If id exists and the classes do not agree, stop running.
However, there is one caveat:
class A: public Base<A,1> {}; class C: public A {}; class D: public A {};
Nothing prevents classes originating from A from colliding.
I can offer static analysis: pick up the C ++ parser and program the binding before commit, which will check the modified files and see if they collide.
Matthieu M.
source share