Whats the difference between a function template , an explicit instantiation , an implicit instantiation and an explicit specialization template ?
following is a function template
template <typename m> //generic function for swapping the values of two arguments
void swap(m &a,m &b){
m temp;
temp=a;
a=b;
b=temp;
}
here is an explicit specialization template for the above function in order to make it swap second element of two structures (if i am not wrong )
struct userinfo(std::string name; int age;};
userinfo user1,user2;
user1={shahab,16};
user2={brendon,15};
template <> void swap<userinfo>(userinfo &a ,userinfo &b){
int temp;
temp=a.age;
a.age=b.age;
b.age=temp;
}
So the questoin begins here,why would you use an explicit specialization in the first place ? i mean look at that ******* function header , its so hard and messed up .
secondly what would be implicit and explicit instantiation in this case ?
I've been trying to digest this for previous 2 days but no progress =/
(not a pro just a determined learner , so please dont go bashing about it if i sounded stupid ,thank you
)