I am feeling template function is more tricky than template class. For the reason that the compiler will do the matching automatically for template function, but for template class, developer can assign how to match.
Sometimes compiler is doing mysterious matching rules for template function, which makes us confused. Does anyone have the same senses? :-)
1. for template function
when we invoke like,
template <class T> void sort (vector <T>&)
sort (vector<int>)&, T will automatically matched by compiler to int -- we have no control. Sometimes, how compiler will do the matching is mysterious. :-)
2. for template class
developer has full control. For example, when use some template class, developer can assign the type of parameter,
when developer use it, we can explicitly assign the type, like Foo <int> or Foo <bool>.
template <class T> class Foo
Any comments or experiences or even disagreement is welcome.
thanks in advance,