summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStephen Kelly <stephen.kelly@kdab.com>2013-09-05 09:43:51 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-05 13:01:27 +0200
commite9a69c3ba928bd88974563b386b000ad6583f969 (patch)
treeb2bf06cff068ad0af0874b10956cdae4650d31f9 /src
parent3062cea229ebd10369c68f08ef4bb5aabd801d5e (diff)
Simplify the smart pointer metatype template
Don't use ## concatenation to create an identifier. That won't work for types in namespaces: Q_DECLARE_SMART_POINTER_METATYPE(QtPrivate::FutureSmartPointer) Change-Id: I876ea93d817724005efc28413f09c01623c2a7a1 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/kernel/qmetatype.h23
1 files changed, 6 insertions, 17 deletions
diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h
index 87d730096b..5ce3f26b53 100644
--- a/src/corelib/kernel/qmetatype.h
+++ b/src/corelib/kernel/qmetatype.h
@@ -1790,21 +1790,15 @@ struct QMetaTypeId< DOUBLE_ARG_TEMPLATE<T, U> > \
};
#define Q_DECLARE_SMART_POINTER_METATYPE(SMART_POINTER) \
-template <typename T, bool = QtPrivate::IsPointerToTypeDerivedFromQObject<T*>::Value> \
-struct QMetaTypeId_ ## SMART_POINTER ## _QObjectStar \
-{ \
- enum { \
- Defined = 0 \
- }; \
-};\
- \
template <typename T> \
-struct QMetaTypeId_ ## SMART_POINTER ## _QObjectStar<T, true> \
+struct QMetaTypeId< SMART_POINTER<T> > \
{ \
enum { \
- Defined = 1 \
+ Defined = QtPrivate::IsPointerToTypeDerivedFromQObject<T*>::Value \
}; \
- static int qt_metatype_id() \
+ static \
+ typename QtPrivate::QEnableIf<QtPrivate::IsPointerToTypeDerivedFromQObject<T*>::Value, int>::Type \
+ qt_metatype_id() \
{ \
static QBasicAtomicInt metatype_id = Q_BASIC_ATOMIC_INITIALIZER(0); \
if (const int id = metatype_id.loadAcquire()) \
@@ -1820,12 +1814,7 @@ struct QMetaTypeId_ ## SMART_POINTER ## _QObjectStar<T, true> \
metatype_id.storeRelease(newId); \
return newId; \
} \
-}; \
-\
-template <typename T> \
-struct QMetaTypeId< SMART_POINTER<T> > : public QMetaTypeId_ ## SMART_POINTER ## _QObjectStar<T> \
-{ \
-};
+};\
#define QT_FOR_EACH_AUTOMATIC_TEMPLATE_SMART_POINTER(F) \
F(QSharedPointer) \