1

就像我使用 VS2010 的主题一样:

我有:

std::string s = std::to_string(42);

和错误

Error   4   error C2668: 'std::to_string' : ambiguous call to overloaded function

如何修复它?

4

1 回答 1

4

Visual C++ 2010 只有三个用于std::to_stringtake long longunsigned long longlong double. 该标准定义了更多,但 VC++ 2010 不支持它们。最好不要从int文字42进行转换,因此调用是模棱两可的。相反,您可以使用不同类型的整数文字。例如:

std::string s = std::to_string(42LL);
于 2013-04-29T22:58:12.057 回答