template <typename T>
struct QMetaTypeId2
{
- enum { Defined = QMetaTypeId<T>::Defined };
+ enum { Defined = QMetaTypeId<T>::Defined, IsBuiltIn=false };
static inline Q_DECL_CONSTEXPR int qt_metatype_id() { return QMetaTypeId<T>::qt_metatype_id(); }
};
QT_BEGIN_NAMESPACE \
template<> struct QMetaTypeId2<NAME> \
{ \
- enum { Defined = 1, MetaType = METATYPEID }; \
+ enum { Defined = 1, IsBuiltIn = true, MetaType = METATYPEID }; \
static inline Q_DECL_CONSTEXPR int qt_metatype_id() { return METATYPEID; } \
}; \
QT_END_NAMESPACE
FOR_EACH_PRIMITIVE_METATYPE(F) \
FOR_EACH_COMPLEX_CORE_METATYPE(F) \
+namespace {
+ template <typename T>
+ struct static_assert_trigger {
+ Q_STATIC_ASSERT(( QMetaTypeId2<T>::IsBuiltIn ));
+ enum { value = true };
+ };
+}
+
+#define CHECK_BUILTIN(MetaTypeName, MetaTypeId, RealType) static_assert_trigger< RealType >::value &&
+Q_STATIC_ASSERT(( FOR_EACH_CORE_METATYPE(CHECK_BUILTIN) true ));
+#undef CHECK_BUILTIN
+Q_STATIC_ASSERT(( QMetaTypeId2<QList<QVariant> >::IsBuiltIn));
+Q_STATIC_ASSERT(( QMetaTypeId2<QMap<QString,QVariant> >::IsBuiltIn));
+Q_STATIC_ASSERT(( QMetaTypeId2<QObject*>::IsBuiltIn));
+Q_STATIC_ASSERT((!QMetaTypeId2<tst_QMetaType*>::IsBuiltIn)); // QObject subclass
+Q_STATIC_ASSERT((!QMetaTypeId2<QList<int> >::IsBuiltIn));
+Q_STATIC_ASSERT((!QMetaTypeId2<QMap<int,int> >::IsBuiltIn));
+Q_STATIC_ASSERT((!QMetaTypeId2<QMetaType::Type>::IsBuiltIn));
+
template <int ID>
struct MetaEnumToType {};
F(QVector4D, QVector4D) \
F(QQuaternion, QQuaternion)
+namespace {
+ template <typename T>
+ struct static_assert_trigger {
+ Q_STATIC_ASSERT(( QMetaTypeId2<T>::IsBuiltIn ));
+ enum { value = true };
+ };
+}
+
+#define CHECK_BUILTIN(TYPE, ID) static_assert_trigger< TYPE >::value &&
+Q_STATIC_ASSERT(( FOR_EACH_GUI_METATYPE(CHECK_BUILTIN) true ));
+#undef CHECK_BUILTIN
+Q_STATIC_ASSERT((!QMetaTypeId2<QList<QPen> >::IsBuiltIn));
+Q_STATIC_ASSERT((!QMetaTypeId2<QMap<QString,QPen> >::IsBuiltIn));
+
template <int ID>
struct MetaEnumToType {};
}
};
+Q_STATIC_ASSERT(( QMetaTypeId2<QSizePolicy>::IsBuiltIn));
+Q_STATIC_ASSERT(( QMetaTypeId2<QWidget*>::IsBuiltIn));
+Q_STATIC_ASSERT((!QMetaTypeId2<QList<QSizePolicy> >::IsBuiltIn));
+Q_STATIC_ASSERT((!QMetaTypeId2<QMap<QString,QSizePolicy> >::IsBuiltIn));
+
+
void tst_QWidgetMetaType::metaObject()
{
QCOMPARE(QMetaType::metaObjectForType(QMetaType::QWidgetStar), &QWidget::staticMetaObject);