C++ to_字符串(42)有多个实例与参数匹配

C++ to_字符串(42)有多个实例与参数匹配,c++,ambiguity,C++,Ambiguity,例如,在我使用VS2010的主题中: 我有: std::string s=std::to_string(42) 错误呢 Error 4 error C2668: 'std::to_string' : ambiguous call to overloaded function 如何修复它? < P> Visual C++ 2010对 STD::ToSoists只有三个重载:采用长long < />代码> 未签名的长long < /代码>,和 long double < />代码>。该标准

例如,在我使用VS2010的主题中:

我有:

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

错误呢

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

如何修复它?

< P> Visual C++ 2010对<代码> STD::ToSoists只有三个重载:采用<代码>长long < />代码> <代码>未签名的长long < /代码>,和<代码> long double < />代码>。该标准定义的不止这些,但VC++2010不支持它们。最好不要从
int
literal
42
进行转换,因此调用不明确。相反,您可以使用不同类型的整型文字。例如:

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

VisualC++ 2010对<代码> STD::ToSoistSuth只有三个重载:采用<代码>长long < />代码>代码>未签名长long < /代码>和<代码> long double < />代码>。该标准定义的不止这些,但VC++2010不支持它们。最好不要从

int
literal
42
进行转换,因此调用不明确。相反,您可以使用不同类型的整型文字。例如:

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

是的…………是的…………42LL在美学上更令人愉悦,我想。@BenjaminLindley我不知道我为什么不这么做。谢谢。我想,42LL在美学上会更讨人喜欢。@BenjaminLindley我不知道我为什么不这么做。谢谢