From 47d2d19cf6bceb0421f5dbff3686ec093daeba1c Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 26 Mar 2014 15:21:38 +0100 Subject: QStringList: add op<< overload for QList MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QStringList << QList already compiled, but was interpreted as QStringList << QStringList(QList), 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 Reviewed-by: Jędrzej Nowacki --- src/corelib/tools/qstringlist.cpp | 10 ++++++++++ src/corelib/tools/qstringlist.h | 2 ++ 2 files changed, 12 insertions(+) (limited to 'src') diff --git a/src/corelib/tools/qstringlist.cpp b/src/corelib/tools/qstringlist.cpp index 3f63b3b8e7..a7379b144c 100644 --- a/src/corelib/tools/qstringlist.cpp +++ b/src/corelib/tools/qstringlist.cpp @@ -478,6 +478,16 @@ QString QtPrivate::QStringList_join(const QStringList *that, const QChar *sep, i the latter string list. */ +/*! + \fn QStringList &QStringList::operator<<(const QList &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 /*! \fn QDataStream &operator>>(QDataStream &in, QStringList &list) diff --git a/src/corelib/tools/qstringlist.h b/src/corelib/tools/qstringlist.h index 11a4d87890..1cdafb4ec2 100644 --- a/src/corelib/tools/qstringlist.h +++ b/src/corelib/tools/qstringlist.h @@ -85,6 +85,8 @@ public: { append(str); return *this; } inline QStringList &operator<<(const QStringList &l) { *this += l; return *this; } + inline QStringList &operator<<(const QList &l) + { *this += l; return *this; } #ifndef QT_NO_REGEXP inline QStringList filter(const QRegExp &rx) const; -- cgit v1.2.3