std::wstring to_wstring( double value );

std::wstring to_wstring( double value );

本文关键字:wstring value double to std      更新时间:2023-10-16

可能的重复项:
std::to_string - 重载函数的多个实例与参数列表匹配

#include <string>
int main()
{
    double randDouble = 1245.432;
    std::wstring stringDouble = std::to_wstring(randDouble);
}

当我在Visual Studio 2010中编译它时,我收到此错误

错误

1 错误 C2668:"std::to_wstring":对重载的不明确调用功能6

1>错误 C2668:'std::to_string":对重载函数的不明确调用

1> d:\Program Files (x86)\Microsoft Visual Studio10.0\vc\include\string(688): 可以是 'std::string std::to_string(long double)'

1> d:\Program Files (x86)\Microsoft Visual Studio10.0\vc\include\string(680): 或 'std::string std::to_string(_ULonglong)'

1> d:\程序文件(x86)\Microsoft Visual Studio 10.0\VC\include\string(672): or
'std::string std::to_string(_Longlong)'

有人可以向我解释为什么编译器感到困惑以及我做错了什么吗?

这是Visual C++ 2010中的一个错误。 此问题已在 Visual C++ 2012 中修复。