From 5c442321220e9ba7818e2eba4fa22b159b6477ab Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 6 Jul 2015 16:55:15 +0200 Subject: QSet/QQueue/QStack: use compiler-generated special member functions They do the right thing (except move special member functions on MSVC, but that's MSVC's problem). Change-Id: I699e1be83c0568821f8c6b84394a2713bb22e8e7 Reviewed-by: Thiago Macieira --- src/corelib/tools/qhash.h | 3 +++ src/corelib/tools/qqueue.h | 3 +-- src/corelib/tools/qset.h | 12 +++--------- src/corelib/tools/qstack.h | 3 +-- 4 files changed, 8 insertions(+), 13 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h index 5a4175ec5d..94cd4c0205 100644 --- a/src/corelib/tools/qhash.h +++ b/src/corelib/tools/qhash.h @@ -916,6 +916,9 @@ public: insert(it->first, it->second); } #endif + // compiler-generated copy/move ctors/assignment operators are fine! + // compiler-generated destructor is fine! + QMultiHash(const QHash &other) : QHash(other) {} void swap(QMultiHash &other) { QHash::swap(other); } // prevent QMultiHash<->QHash swaps diff --git a/src/corelib/tools/qqueue.h b/src/corelib/tools/qqueue.h index 9d5bda1210..7a7abab070 100644 --- a/src/corelib/tools/qqueue.h +++ b/src/corelib/tools/qqueue.h @@ -43,8 +43,7 @@ template class QQueue : public QList { public: - inline QQueue() {} - inline ~QQueue() {} + // compiler-generated special member functions are fine! inline void swap(QQueue &other) { QList::swap(other); } // prevent QList<->QQueue swaps #ifndef Q_QDOC // bring in QList::swap(int, int). We cannot say using QList::swap, diff --git a/src/corelib/tools/qset.h b/src/corelib/tools/qset.h index 5a9c75fe07..aeba6cf68d 100644 --- a/src/corelib/tools/qset.h +++ b/src/corelib/tools/qset.h @@ -57,15 +57,9 @@ public: insert(*it); } #endif - inline QSet(const QSet &other) : q_hash(other.q_hash) {} - - inline QSet &operator=(const QSet &other) - { q_hash = other.q_hash; return *this; } -#ifdef Q_COMPILER_RVALUE_REFS - inline QSet(QSet &&other) : q_hash(qMove(other.q_hash)) {} - inline QSet &operator=(QSet &&other) - { qSwap(q_hash, other.q_hash); return *this; } -#endif + // compiler-generated copy/move ctor/assignment operators are fine! + // compiler-generated destructor is fine! + inline void swap(QSet &other) { q_hash.swap(other.q_hash); } inline bool operator==(const QSet &other) const diff --git a/src/corelib/tools/qstack.h b/src/corelib/tools/qstack.h index fa05e22de1..278e89ca2f 100644 --- a/src/corelib/tools/qstack.h +++ b/src/corelib/tools/qstack.h @@ -43,8 +43,7 @@ template class QStack : public QVector { public: - inline QStack() {} - inline ~QStack() {} + // compiler-generated special member functions are fine! inline void swap(QStack &other) { QVector::swap(other); } // prevent QVector<->QStack swaps inline void push(const T &t) { QVector::append(t); } T pop(); -- cgit v1.2.3