I am baffled by this error:
#include <string>
#include <iostream>
void f(int, std::string) {std::cout << "f1\n";}
template <class T>
void f(std::string, T&&) {std::cout << "f2\n";}
void f(int) {std::cout << "f3\n";}
void f(std::string) {std::cout << "f4\n";}
int main() {
// f(0, "as"); // call of overloaded 'f(int, const char [3])' is ambiguous
f(1, "as");
f(0);
}
The first line does not compile and I can't figure out why.
The second line does compile, even though it is the same types.
The third line does compile, even though it is the same conversion.
Huh?