Simplify toStdWString
In C++17: just use std::basic_string::data(). In C++11: dereferencing begin() on an empty string is undefined behavior on all compilers, not just MSVC, so remove that workaround. Instead of the reference-dereference combo, use std::basic_string::front(). Change-Id: I3229597e000311ce71e4083dca6667bb56d8f8e3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
d41a46bc39
commit
40e4ab673a
@ -1380,14 +1380,12 @@ inline std::wstring QString::toStdWString() const
|
|||||||
{
|
{
|
||||||
std::wstring str;
|
std::wstring str;
|
||||||
str.resize(length());
|
str.resize(length());
|
||||||
|
#if __cplusplus >= 201703L
|
||||||
#ifdef Q_CC_MSVC
|
str.resize(toWCharArray(str.data()));
|
||||||
// VS2005 crashes if the string is empty
|
#else
|
||||||
if (!length())
|
if (length())
|
||||||
return str;
|
str.resize(toWCharArray(&str.front()));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
str.resize(toWCharArray(&(*str.begin())));
|
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user