What the best way to make a function template with the same parameters?
For example:
template<class T>
int foo(const T &item) {
// ...
return item;
};
template<class T, class NotUsed>
char foo(const T &item) {
// ...
return item;
};
int main()
{
std::cout << foo(1) << std::endl; // 1
std::cout << foo('1') << std::endl; // 1
return 0;
}
From what your trying to do I would suggest making the return type a template parameter.