Let's say we have a template function:
template <class T> T max(T a, T b) { return a > b ? a : b; }
Since the compiler doesn't perform any implicit type conversion during template argument deduction, we can invoke max(2, 5.5)
in these two ways:
- Using casting :
max(static_cast<float>(2), 5.5f);
- Using explicit template instantiation :
max<float>(2, 5.5);
Second case makes sense to me, but when do we do the explicit template instantiation in the given below way (instantiating without invoking the function max
with char type):
template char max(char a, char b);
What do we achieve out of it?