QString: fix append/prepend/insert/op+= with QT_RESTRICTED_CAST_FROM_ASCII
Since adding the QUtf8StringView overloads, calling these overload sets with const char string literals became ambiguous in QT_RESTRICTED_CAST_FROM_ASCII builds (both QString and QUtf8StringView are a match). Fix by providing the same templated overloads that QT_RESTRICTED_CAST_FROM_ASCII enables for QString construction and assignment for append/prepend/insert/op+=, too. Incidentally, this makes these operations much faster than when they constructed a temporary QString. Change-Id: Ie9b38fc80cc00e142e094dab716938c6fda41ba1 Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Alessandro Portale <alessandro.portale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
parent
1ecbab76b6
commit
50a0c4f3ce
@ -717,6 +717,17 @@ public:
|
||||
inline QString &operator+=(QLatin1StringView s) { return append(s); }
|
||||
QString &operator+=(QUtf8StringView s) { return append(s); }
|
||||
|
||||
#if defined(QT_RESTRICTED_CAST_FROM_ASCII)
|
||||
template <qsizetype N>
|
||||
QString &insert(qsizetype i, const char (&ch)[N]) { return insert(i, QUtf8StringView(ch)); }
|
||||
template <qsizetype N>
|
||||
QString &append(const char (&ch)[N]) { return append(QUtf8StringView(ch)); }
|
||||
template <qsizetype N>
|
||||
QString &prepend(const char (&ch)[N]) { return prepend(QUtf8StringView(ch)); }
|
||||
template <qsizetype N>
|
||||
QString &operator+=(const char (&ch)[N]) { return append(QUtf8StringView(ch)); }
|
||||
#endif
|
||||
|
||||
QString &remove(qsizetype i, qsizetype len);
|
||||
QString &remove(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive);
|
||||
QString &remove(QLatin1StringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive);
|
||||
|
Loading…
x
Reference in New Issue
Block a user