The fact that you can't overload on return type doesn't mean you can't simplify the process a bit under certain circumstances, e.g. if your return type is constructible from your input type.
template <typename T> T get(int i)
{
return T(i);
}
int main()
{
int i = get<int>(65);
char c = get<char>(65);
return 0;
}
The code above might be mistaken for an overload when in fact it's not. You will have to specify the return type when you call the function as the template argument. Sometimes this can be useful, but in effect, it is not different from implementing one method for each return type, like
int getInt(int i)
and
char getChar(int i)
.