错误:'operator&lt;&lt;'的模糊重载(操作数类型是'std :: ostream {aka std :: basic_ostream <char>}'和'<unnamed-signed:128>')</unnamed-signed:128> </char>

时间:2015-03-29 08:36:07

标签: c++ c++11

这是我的代码:

#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;
}

以下是编制者的抱怨:

[Error] ambiguous overload for 'operator<<' (operand types are 'std::ostream {aka std::basic_ostream<char>}' and '<unnamed-signed:128>')

当我将sum的seconed参数更改为12时,此代码编译无怨言。

0 个答案:

没有答案