This forces the creation of this version of the function template. It does not have much value in the case of our program example, but it can be useful when you know that several versions of a template function might be generated, but you want to force the generation of a subset that you plan to use, with arguments cast to the appropriate type where necessary.
I think, it talks about synthesis of different functions of template according to the data types used.
so, if you have this: template< class T > void max( T& , int& );
and in your program you do this:
1 2 3
max(int, int);
max(float, int);
max(double, int);
three functions would be generated, one for int, float and double.
It also says, if you want to force generation of subsets. This can be done using typecasting. But you should know what you are doing. something like this:
Explicit template instantiations can be used in large code bases to speed up compilation and/or minimize code bloat. Briefly,
If we have a template that is only required to be used only with a few explicit types (in other words, a small subset of all possible types):
We can place the template declaration in a header file.
Place the template definition in a normal source file; and then explicitly instantiate the template for the subset of types for which the template is to be made available.