|
|
A specialization is a particular instance of a template function or data item that overrides the template version. This might be done, for example, to improve performance for specific common cases. Some examples of specializations:
template <class T> void f(T) {} // templatetemplate<> void f(char* s) {} // specialization
template <class T> struct A {void f();} // template
template<> void A<int>::f() {} // specialization
template <class T> struct B {static int x;}; // template template <class T> int A<T>::x = 37;
template<> int A<double>::x = -59; // specialization
Such specializations are automatically picked up by the link simulation mentioned earlier, and they override general templates.