QString: add some missing overloaded operator+
to keep compatibility with and without using QT_USE_QSTRINGBUILDER. Change-Id: If8218fe0693cdb7ad1250beb272e0e7c356bbf4a Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
parent
d0e4f28dea
commit
5c9e393117
@ -1725,6 +1725,23 @@ inline bool QStringRef::contains(const QStringRef &s, Qt::CaseSensitivity cs) co
|
||||
inline QString &QString::insert(int i, const QStringRef &s)
|
||||
{ return insert(i, s.constData(), s.length()); }
|
||||
|
||||
#if !defined(QT_USE_FAST_OPERATOR_PLUS) && !defined(QT_USE_QSTRINGBUILDER)
|
||||
inline QString operator+(const QString &s1, const QStringRef &s2)
|
||||
{ QString t; t.reserve(s1.size() + s2.size()); t += s1; t += s2; return t; }
|
||||
inline QString operator+(const QStringRef &s1, const QString &s2)
|
||||
{ QString t; t.reserve(s1.size() + s2.size()); t += s1; t += s2; return t; }
|
||||
inline QString operator+(const QStringRef &s1, QLatin1String s2)
|
||||
{ QString t; t.reserve(s1.size() + s2.size()); t += s1; t += s2; return t; }
|
||||
inline QString operator+(QLatin1String s1, const QStringRef &s2)
|
||||
{ QString t; t.reserve(s1.size() + s2.size()); t += s1; t += s2; return t; }
|
||||
inline QString operator+(const QStringRef &s1, const QStringRef &s2)
|
||||
{ QString t; t.reserve(s1.size() + s2.size()); t += s1; t += s2; return t; }
|
||||
inline QString operator+(const QStringRef &s1, QChar s2)
|
||||
{ QString t; t.reserve(s1.size() + 1); t += s1; t += s2; return t; }
|
||||
inline QString operator+(QChar s1, const QStringRef &s2)
|
||||
{ QString t; t.reserve(1 + s2.size()); t += s1; t += s2; return t; }
|
||||
#endif // !(QT_USE_FAST_OPERATOR_PLUS || QT_USE_QSTRINGBUILDER)
|
||||
|
||||
namespace Qt {
|
||||
#if QT_DEPRECATED_SINCE(5, 0)
|
||||
QT_DEPRECATED inline QString escape(const QString &plain) {
|
||||
|
@ -73,8 +73,22 @@ void runScenario()
|
||||
QCOMPARE(r, r2);
|
||||
r = stringref Q stringref;
|
||||
QCOMPARE(r, QString(stringref.toString() + stringref.toString()));
|
||||
r = stringref P stringref;
|
||||
QCOMPARE(r, QString(stringref.toString() + stringref.toString()));
|
||||
r = string P l1string;
|
||||
QCOMPARE(r, r2);
|
||||
r = l1string P stringref;
|
||||
QCOMPARE(r, QString(l1string + stringref.toString()));
|
||||
r = stringref P l1string;
|
||||
QCOMPARE(r, QString(stringref.toString() + l1string));
|
||||
r = stringref P string;
|
||||
QCOMPARE(r, QString(stringref.toString() + string));
|
||||
r = string P stringref;
|
||||
QCOMPARE(r, QString(string + stringref.toString()));
|
||||
r = stringref P achar;
|
||||
QCOMPARE(r, QString(stringref.toString() + achar));
|
||||
r = achar P stringref;
|
||||
QCOMPARE(r, QString(achar + stringref.toString()));
|
||||
r = string Q QStringLiteral(LITERAL);
|
||||
QCOMPARE(r, r2);
|
||||
r = QStringLiteral(LITERAL) Q string;
|
||||
|
Loading…
Reference in New Issue
Block a user