diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2012-02-28 19:54:46 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-03-01 14:26:06 +0100 |
commit | 15c141511fab24233d42b3c8593f0781a4931c8a (patch) | |
tree | b0447061da9bcb9e5fa94f40687041ea63e0e783 /src/corelib/tools/qpair.h | |
parent | e17440586252551c6de169d9141daef1c31a1e7e (diff) |
QPair: specialise QTypeInfo based on the typeinfos of its arguments
Specialise QTypeInfo<QPair<T1,T2>> based on the properties of
T1 and T2:
- If either T1 or T2 is Q_COMPLEX_TYPE, so is QPair<T1,T2>.
- Otherwise, if either T1 or T2 is Q_MOVABLE_TYPE, so is QPair<T1,T2>.
- Otherwise, QPair<T1,T2> is Q_PRIMITIVE_TYPE.
Change-Id: I8aecbd37e3b7924f77f38967498deabf1a19ca24
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
Diffstat (limited to 'src/corelib/tools/qpair.h')
-rw-r--r-- | src/corelib/tools/qpair.h | 16 |
1 files changed, 16 insertions, 0 deletions
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<T1,T2> as complex/movable/primitive depending on the +// typeinfos of the constituents: +template<class T1, class T2> +class QTypeInfo< QPair<T1, T2> > +{ +public: + enum { + isComplex = QTypeInfo<T1>::isComplex || QTypeInfo<T2>::isComplex, + isStatic = QTypeInfo<T1>::isStatic || QTypeInfo<T2>::isStatic, + isLarge = sizeof(QPair<T1, T2>) > sizeof(void*), + isPointer = false, + isDummy = false, + sizeOf = sizeof(QPair<T1, T2>) + }; +}; + template <class T1, class T2> Q_INLINE_TEMPLATE bool operator==(const QPair<T1, T2> &p1, const QPair<T1, T2> &p2) { return p1.first == p2.first && p1.second == p2.second; } |