Here the compiler warns that the two instances of the CommonBase class template are of the same type while they are not: one is CommonBase<Tuple<N, Real> > and the other one is CommonBase<Vector<N, Real> >. However, the compiler does the right thing despite this warning. It is the warning message that is in error. Btw, do not try to use this technique to implement vectors since multiple inheritance takes additional memory.
template <typename Type>
class CommonBase
{
};
template <int N, typename Real, typename Derived>
class TupleBase
: CommonBase<Derived>
{
};
template <int N, typename Real>
class Tuple
: public TupleBase<N, Real, Tuple<N, Real> >
{
};
template <int N, typename Real, typename Derived>
class VectorBase
: public Tuple<N, Real>
, CommonBase<Derived>
{
};
template <int N, typename Real>
class Vector
: public VectorBase<N, Real, Vector<N, Real> >
{
};
int main()
{
return 0;
}