Is static member variable initialized in a template class if the static menber is not used?
问题 Is static member variable initialized in a template class if the static member is not used? I use it to register the type. template<class T> class A { static bool d; }; template<class T> bool A<T>::d = [](){regist<A<T>>(); return true;}(); int main() { A<int> a; return 0; } I find a way to test it. It prints 1 other than 2. The regist() is not called abd the static member is not initialized. My testing is on VC110 compilter. And I also test it online #include <iostream> using namespace std;