Auto return type of template and ambiguity
问题 I have an overloaded template function: template<typename T1, typename T2> auto overMax(T1 a, T2 b) { std::cout << __FUNCSIG__ << std::endl; return b < a ? a : b; } template<typename RT, typename T1, typename T2> RT overMax(T1 a, T2 b) { std::cout << __FUNCSIG__ << std::endl; return b < a ? a : b; } If I call it like this: auto a = overMax(4, 7.2); // uses first template auto b = overMax<double>(4, 7.2); // uses second template everything works perfect, but auto c = overMax<int>(4, 7.2); //