extern template & incomplete types
问题 Recently when I was trying to optimize my include hierarchy I stumbled upon the file a.hpp : template<class T> class A { using t = typename T::a_t; }; class B; extern template class A<B>; which seems to be ill-formed. In fact it seems as if the extern template statement at the end causes an instantiation of A<B> which causes the compiler to complain about an incomplete type. My goal would have been to define A<B> in a.cpp : #include <b.hpp> template class A<B>; This way I avoid having to