dimanche 29 mars 2015

Here is my code:



#include<iostream>

template <typename T1, typename T2>
auto sum(const T1 &v1, const T2 &v2) -> decltype(v1 + v2)
{
return v1 + v2;
}

int main()
{
std::cout << sum(12, 123456789123456789123456789123456789123456789) << std::endl;
return 0;
}


Here is the compiler's complaint:


[Error] ambiguous overload for 'operator<<' (operand types are 'std::ostream {aka std::basic_ostream}' and '')


When I changed the seconed argument of sum to 12, this code compiled without complaint. I nee


Aucun commentaire:

Enregistrer un commentaire