Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/136.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 将int转换为wstring_C++_String_Type Conversion - Fatal编程技术网

C++ 将int转换为wstring

C++ 将int转换为wstring,c++,string,type-conversion,C++,String,Type Conversion,我想将整数值(int)转换为std::wstring。最好的方法是什么?我是为windows phone开发的,所以我宁愿避免使用外部库(如boost::lexical_cast)。我正在寻找一些简单的东西,最好是一行代码,只将int赋值给wstring 任何帮助都将不胜感激。您在寻找什么 将带符号十进制整数转换为宽字符串,其内容与std::swprintf(buf,sz,L“%d”,value)为足够大的buf生成的内容相同 size\u t myInteger=10; std::wostri

我想将整数值(int)转换为std::wstring。最好的方法是什么?我是为windows phone开发的,所以我宁愿避免使用外部库(如boost::lexical_cast)。我正在寻找一些简单的东西,最好是一行代码,只将int赋值给wstring

任何帮助都将不胜感激。

您在寻找什么

将带符号十进制整数转换为宽字符串,其内容与std::swprintf(buf,sz,L“%d”,value)为足够大的buf生成的内容相同

size\u t myInteger=10;
std::wostringstream myStringStream;

myStringStream@WhozCraig我也没有,我正试图找到我想要的
wstring
页面。答案再好不过了。我甚至不知道这是可用的。当我在谷歌上搜索我的问题时,什么也没有出现。难怪编码世界如此混乱,半实现的标准对IT行业感到厌恶
std::wstring to_wstring( int value );   (since C++11)
    size_t myInteger = 10;
    std::wostringstream myStringStream;
    myStringStream<< L"myText" << myInteger;
    std::wstring concatenatedStr = myStringStream.str();