I have template function "compare" defined as below.
#include<iostream>
using namespace std;
template<typename T>
void compare(const T&a, const T& b)
{
cout<<"Inside compare"<<endl;
}
main()
{
compare("aa","bb");
compare("aa","bbbb");
}
When i instantiate compare with string literals of same length, the compiler doesnot complain. When i do it with literals of different length,it says "error: no matching function for call to compare(const char[3],const char[5])"
I am confused as compare function should be instantiated with character pointer rather than character array. Should not string literals always decay to pointer?