Convert QStringView::toWCharArray() to return qsizetype

As requested in a ### Qt6 comment.

Task-number: QTBUG-85700
Change-Id: I28a02bf49f4a6455a21a6032179318ce2915b8ca
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Edward Welbourne 2020-08-13 15:30:59 +02:00
parent 34a095848d
commit 429985b53a
2 changed files with 4 additions and 4 deletions

View File

@ -1079,14 +1079,14 @@ inline qsizetype QString::toWCharArray(wchar_t *array) const
return qToStringViewIgnoringNull(*this).toWCharArray(array);
}
int QStringView::toWCharArray(wchar_t *array) const
qsizetype QStringView::toWCharArray(wchar_t *array) const
{
if (sizeof(wchar_t) == sizeof(QChar)) {
if (auto src = data())
memcpy(array, src, sizeof(QChar) * size());
return int(size()); // ### q6sizetype
return size();
} else {
return QString::toUcs4_helper(reinterpret_cast<const ushort *>(data()), int(size()),
return QString::toUcs4_helper(reinterpret_cast<const ushort *>(data()), size(),
reinterpret_cast<uint *>(array));
}
}

View File

@ -358,7 +358,7 @@ public:
Q_REQUIRED_RESULT Q_CORE_EXPORT float toFloat(bool *ok = nullptr) const;
Q_REQUIRED_RESULT Q_CORE_EXPORT double toDouble(bool *ok = nullptr) const;
Q_REQUIRED_RESULT inline int toWCharArray(wchar_t *array) const; // defined in qstring.h
Q_REQUIRED_RESULT inline qsizetype toWCharArray(wchar_t *array) const; // defined in qstring.h
Q_REQUIRED_RESULT Q_CORE_EXPORT