From 15c141511fab24233d42b3c8593f0781a4931c8a Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 28 Feb 2012 19:54:46 +0100 Subject: QPair: specialise QTypeInfo based on the typeinfos of its arguments Specialise QTypeInfo> based on the properties of T1 and T2: - If either T1 or T2 is Q_COMPLEX_TYPE, so is QPair. - Otherwise, if either T1 or T2 is Q_MOVABLE_TYPE, so is QPair. - Otherwise, QPair is Q_PRIMITIVE_TYPE. Change-Id: I8aecbd37e3b7924f77f38967498deabf1a19ca24 Reviewed-by: Olivier Goffart Reviewed-by: Thiago Macieira Reviewed-by: Stephen Kelly --- src/corelib/tools/qpair.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/corelib/tools/qpair.h') diff --git a/src/corelib/tools/qpair.h b/src/corelib/tools/qpair.h index 501f2af3e6..29eb58bd22 100644 --- a/src/corelib/tools/qpair.h +++ b/src/corelib/tools/qpair.h @@ -65,6 +65,22 @@ struct QPair T2 second; }; +// mark QPair as complex/movable/primitive depending on the +// typeinfos of the constituents: +template +class QTypeInfo< QPair > +{ +public: + enum { + isComplex = QTypeInfo::isComplex || QTypeInfo::isComplex, + isStatic = QTypeInfo::isStatic || QTypeInfo::isStatic, + isLarge = sizeof(QPair) > sizeof(void*), + isPointer = false, + isDummy = false, + sizeOf = sizeof(QPair) + }; +}; + template Q_INLINE_TEMPLATE bool operator==(const QPair &p1, const QPair &p2) { return p1.first == p2.first && p1.second == p2.second; } -- cgit v1.2.3