QStringList: add op<< overload for QList<QString>
QStringList << QList<QString> already compiled, but was interpreted as QStringList << QStringList(QList<QString>), which involves the QList copy ctor. Adding the overload saves that copy. Cannot use a using declaration here, since the return type is different. Change-Id: I119cc98e7e2df24549a1abb158543b729edc30ef Reviewed-by: Olivier Goffart <ogoffart@woboq.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
This commit is contained in:
parent
2a9d3b7a46
commit
47d2d19cf6
@ -478,6 +478,16 @@ QString QtPrivate::QStringList_join(const QStringList *that, const QChar *sep, i
|
|||||||
the latter string list.
|
the latter string list.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn QStringList &QStringList::operator<<(const QList<QString> &other)
|
||||||
|
\since 5.4
|
||||||
|
|
||||||
|
\overload
|
||||||
|
|
||||||
|
Appends the \a other string list to the string list and returns a reference to
|
||||||
|
the latter string list.
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef QT_NO_DATASTREAM
|
#ifndef QT_NO_DATASTREAM
|
||||||
/*!
|
/*!
|
||||||
\fn QDataStream &operator>>(QDataStream &in, QStringList &list)
|
\fn QDataStream &operator>>(QDataStream &in, QStringList &list)
|
||||||
|
@ -85,6 +85,8 @@ public:
|
|||||||
{ append(str); return *this; }
|
{ append(str); return *this; }
|
||||||
inline QStringList &operator<<(const QStringList &l)
|
inline QStringList &operator<<(const QStringList &l)
|
||||||
{ *this += l; return *this; }
|
{ *this += l; return *this; }
|
||||||
|
inline QStringList &operator<<(const QList<QString> &l)
|
||||||
|
{ *this += l; return *this; }
|
||||||
|
|
||||||
#ifndef QT_NO_REGEXP
|
#ifndef QT_NO_REGEXP
|
||||||
inline QStringList filter(const QRegExp &rx) const;
|
inline QStringList filter(const QRegExp &rx) const;
|
||||||
|
@ -321,7 +321,12 @@ void tst_QStringList::streamingOperator()
|
|||||||
list << "hei";
|
list << "hei";
|
||||||
list << list << "hopp" << list;
|
list << list << "hopp" << list;
|
||||||
|
|
||||||
|
QList<QString> slist = list;
|
||||||
|
list << slist;
|
||||||
|
|
||||||
QCOMPARE(list, QStringList()
|
QCOMPARE(list, QStringList()
|
||||||
|
<< "hei" << "hei" << "hopp"
|
||||||
|
<< "hei" << "hei" << "hopp"
|
||||||
<< "hei" << "hei" << "hopp"
|
<< "hei" << "hei" << "hopp"
|
||||||
<< "hei" << "hei" << "hopp");
|
<< "hei" << "hei" << "hopp");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user