The impact of virtual on the use of member of class template
问题 I (vaguely) know that a template is not instantiated if it is not used . For example, the following code will compile fine even though T::type doesn't make sense when T = int . template<typename T> struct A { void f() { using type = typename T::type; } }; A<int> a; //ok It compiles because f() is not used , so it is not instantiated — thus the validity of T::type remains unchecked. It doesn't matter if some other member function g() calls f() . template<typename T> struct A { void f() { using