重载函数to_string的多个实例与参数列表匹配

More than one instance of overloaded function to_string matches the argument list

本文关键字:实例 参数 列表 to 函数 string 重载      更新时间:2023-10-16

我完全按照这里写的做了:在C++中将 int 转换为字符串的最简单方法

但是我在 std::to_string 的标准处出现错误

#include <iostream>
#include <string>
int main()
{
std::string s = std::to_string(42);
return 0;
}

无法为符合标准的库实现生成收到的错误消息。

因此,最好的解决方案是升级编译器(大概是几年前的Visual C++)。

另一种方法是使用类型 long 的参数,并希望这是现有的重载之一:

std::to_string( 42L )