Defined in header <string> | ||
---|---|---|
std::wstring to_wstring( int value ); | (1) | (since C++11) |
std::wstring to_wstring( long value ); | (2) | (since C++11) |
std::wstring to_wstring( long long value ); | (3) | (since C++11) |
std::wstring to_wstring( unsigned value ); | (4) | (since C++11) |
std::wstring to_wstring( unsigned long value ); | (5) | (since C++11) |
std::wstring to_wstring( unsigned long long value ); | (6) | (since C++11) |
std::wstring to_wstring( float value ); | (7) | (since C++11) |
std::wstring to_wstring( double value ); | (8) | (since C++11) |
std::wstring to_wstring( long double value ); | (9) | (since C++11) |
Converts a numeric value to std::wstring
.
std::swprintf(buf, sz, L"%d", value)
would produce for sufficiently large buf
.std::swprintf(buf, sz, L"%ld", value)
would produce for sufficiently large buf
..std::swprintf(buf, sz, L"%lld", value)
would produce for sufficiently large buf
.std::swprintf(buf, sz, L"%u", value)
would produce for sufficiently large buf
.std::swprintf(buf, sz, L"%lu", value)
would produce for sufficiently large buf
.std::swprintf(buf, sz, L"%llu", value)
would produce for sufficiently large buf
.std::swprintf(buf, sz, L"%f", value)
would produce for sufficiently large buf
.std::swprintf(buf, sz, L"%Lf", value)
would produce for sufficiently large buf
.value | - | a numeric value to convert |
a wide string holding the converted value.
#include <string> #include <iostream> int main() { double f = 23.43; std::wstring f_str = std::to_wstring(f); std::wcout << f_str; }
Output:
23.430000
(C++11) | converts an integral or floating point value to string (function) |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
http://en.cppreference.com/w/cpp/string/basic_string/to_wstring