Is this the right way to initialize static elements of data from template classes?

Is this the right way to initialize static elements of data from template classes?

template <typename T> class Temp { public: static unsigned int x; }; template <typename T> unsigned int Temp<T>::x = 0; 
+6
source share
1 answer

Yes. Yes it is.

[C++11: 14.5.1.3/1] A definition for a static data item can be provided in a namespace area that encompasses the definition of a static member class template. [Example:

 template<class T> class X { static T s; }; template<class T> T X<T>::s = 0; 

-end example]

+7
source

All Articles