Cleanup container declarations in qtypeinfo.h

Use variadic templates to avoid having to use several macros to
declare movable containers.

Add missing movable declaration for QCache.

Change-Id: I32d6a399ef8e6c39021df04deedfbbf0c526fc84
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Lars Knoll 2020-10-25 14:12:31 +01:00
parent 742de50c5e
commit 7d75a48507
2 changed files with 5 additions and 22 deletions

View File

@ -117,9 +117,8 @@ public:
};
#define Q_DECLARE_MOVABLE_CONTAINER(CONTAINER) \
template <typename T> class CONTAINER; \
template <typename T> \
class QTypeInfo< CONTAINER<T> > \
template <typename ...T> \
class QTypeInfo<CONTAINER<T...>> \
{ \
public: \
enum { \
@ -134,27 +133,11 @@ Q_DECLARE_MOVABLE_CONTAINER(QList);
Q_DECLARE_MOVABLE_CONTAINER(QQueue);
Q_DECLARE_MOVABLE_CONTAINER(QStack);
Q_DECLARE_MOVABLE_CONTAINER(QSet);
#undef Q_DECLARE_MOVABLE_CONTAINER
#define Q_DECLARE_MOVABLE_CONTAINER(CONTAINER) \
template <typename K, typename V> class CONTAINER; \
template <typename K, typename V> \
class QTypeInfo< CONTAINER<K, V> > \
{ \
public: \
enum { \
isPointer = false, \
isIntegral = false, \
isComplex = true, \
isRelocatable = true, \
}; \
}
Q_DECLARE_MOVABLE_CONTAINER(QMap);
Q_DECLARE_MOVABLE_CONTAINER(QMultiMap);
Q_DECLARE_MOVABLE_CONTAINER(QHash);
Q_DECLARE_MOVABLE_CONTAINER(QMultiHash);
Q_DECLARE_MOVABLE_CONTAINER(QCache);
#undef Q_DECLARE_MOVABLE_CONTAINER

View File

@ -37,11 +37,11 @@
**
****************************************************************************/
#include <QtCore/qglobal.h>
#ifndef QCONTAINERFWD_H
#define QCONTAINERFWD_H
#include <QtCore/qglobal.h>
// std headers can unfortunately not be forward declared
#include <tuple>
#include <variant>