Can someone explain to me why the following code gives an error?
#include <iostream>
using namespace std;
template <typename aa, typename bb>
auto minimum(aa a, bb b)
{
if (a < b) return a;
else return b;
}
int main()
{
cout << minimum(7, 5.1);
}
inconsistent deduction for 'auto': 'int' and then 'double'
Why does this code work without error?
#include <iostream>
using namespace std;
template <typename aa, typename bb>
auto minimum(aa a, bb b)
{
return a < b ? a : b;
}
int main()
{
cout << minimum(7, 5.1);
}