I have a template function as below which has one of the arguments a constant
template<typename T>
T maxAmong( T x, const T y) {
return x ;
}
For explicit specialization I expected to have the below code. But this gives a compile error.
template<> char* maxAmong( char* x, const char* y) {
return x;
}
Whereas the making both return type and both arguments const works
template<> const char* maxAmong( const char* x, const char* y) {
return x;
}
Why does the code in second snippet fail as for me the code looks more right that way.