If I’m developing for Windows and some WinAPI functions require me to use LPWSTR as string data type. Is it okay to use C++11’s u16string in my library? Are those two data types the same thing?
It looks more like LPWSTR is wchar_t, but nobody likes wchar_t anymore…
The C++11
char16_ttype is distinct fromwchar_t. In theory you couldreinterpret_castyour way betweenchar16_t*and Windows’wchar_t*(Windows’wchar_tis 16 bits). In practice, however, Visual C++ 10.0 – and I think also Visual C++ 11.0 – lacks support for Unicode literals likeu'A'oru"A".Summing up (I’ve found that on SO one should better make all conclusions explicit):
“Is it okay to use C++11’s u16string in my library?”
Certainly, but not as direct plug-in replacements for
wchar_tstrings, and as of 2012 currently problematic (due to lack of support for literals) if you plan on supporting Visual C++.“Are those two data types the same thing?”
No.
“nobody likes wchar_t anymore…”
That’s certainly not the case.