This will fix unused-include false positive.
// primary.h namespace ns { template<class T1, class T2> class Z {}; // primary template } // partial.h namespace ns { template<class T> class Z<T, T*> {}; // partial specialization } // main.cpp using ns::Z; // refs to the primary void k() { Z<int, int*> z; // use the partial specialization }
nit: prefer early exit