This is my second contribution to the evilzone community , i asked this question myself the previous day and me hell sure many other c++ coders would be confused too in it afterall , so i couldn't find anybody to help me ,instead i banged my head many times and finally got the answer , so just a little explanation to the others about it
MAKE SURE YOU KNOW ABOUT FUNCTIONS AND A LITTLE ABOUT GENERIC TYPE FUNCTIONS IN C++
okay so just a structure i will be using in the below example
struct userinfo( std::string name; int age;);
explicit specialization is making a function template for a particular type , that is you mention the type of arguments to be used with the function EXPLICITLY in the function prototype and definition
template <typename whatever> //function for generic type
void swap(whatever&a,whatever&b){
whatever temp;
temp=a;
a=b;
b=temp:}
the above is a function template for generic type means any type of integers could be used while calling the function and the compiler will use them .the function will work for every type but suppose you want to change the second element of a structure with another , there comes explicit SPECIALIZATION to the rescue
template <> void swap<userinfo>(userinfo &a ,userinfo &b){
int temp=a.age;
a.age=b.age;
b.age=temp;}
the above is explicit specialization for a structure (userinfo) , that is if the compiler reaches the call to the swap function with userinfo type arguments then it will go with the explicitly specialized definition of the function .
instantiations on the other hands are CALLS to the function defined before , you can NOT use an EXPLICIT INSTANTIATION with an EXPLICITLY SPECIALIZED function
like calling the generic function template(Swap) this way
double a=2;
double b=3;
swap(a,b);
is an example of IMPLICIT instantiation means you call the function without mentioning what type of variables you are using as arguments .
EXPLICIT instantiation on the other hand is the call to a generic function template , in such a call you mention that what type of variables you are using suppose the following
swap <int>(a,b);
the above is an EXPLICIT instantiation means the CALL to the generic function in which you mention that both the variables are INT and must be treated the way INT are treated .
however you can't explicitly instantiate an EXPLICITLY SPECIALIZED TEMPLATE
*phew had to bang my hard many times just to digest this :/ , cheers everybody ,thanks for the support*
-regards
MR KHAN