In some cases, it isn’t possible or desirable for a template to define exactly the same code for any type. In such cases you can define a specialization of the template for that particular type. When a user instantiates the template with that type, the compiler uses the specialization to generate the class, and for all other types, the compiler chooses the more general template.
* Specializations in which all parameters are specialized are complete specializations.
* If only some of the parameters are specialized, it is called a partial specialization.
```
#include <string>
#include <iostream>
using namespace std;
template <typename K, typename V> class MyMap{
public:
MyMap() { cout<<"KV"<<endl;}
};
// partial specialization for string keys
template<typename V> class MyMap<string, V>{
public:
MyMap() { cout<<"V"<<endl;}
};
int main() {
MyMap<int, string> strings1; // uses original template
MyMap<string, string> strings2{}; // uses the partial specialization
}
```