summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2012-07-20 15:46:40 +0200
committerQt by Nokia <qt-info@nokia.com>2012-07-26 15:01:04 +0200
commite083d253950d3e7ce1e6363cd29fba416e69e371 (patch)
tree7990f2da2be356bb4d6dd30190d3646524d816db /tests/auto/gui
parentf694b9c83fc4512228d5c9b3384bf7f2e03bb5d5 (diff)
QMetaTypeId2::IsBuiltIn: (new) template meta-function to check for built-in types
This allows to check whether QMetaTypeId2::MetaType exists, and can help turn run-time into compile-time expressions, even without constexpr support, or in situations where constexpr can't be used (because you can't overload on it). This was designed for the QMetaType::registerConversion feature, but it's much more widely applicable. Change-Id: Iafa04add04bcb531b3f7fe3e751c7e91ee6a3bc0 Reviewed-by: Olivier Goffart <ogoffart@woboq.com> Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com>
Diffstat (limited to 'tests/auto/gui')
-rw-r--r--tests/auto/gui/kernel/qguimetatype/tst_qguimetatype.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/auto/gui/kernel/qguimetatype/tst_qguimetatype.cpp b/tests/auto/gui/kernel/qguimetatype/tst_qguimetatype.cpp
index 0514eafa2d..fae999556f 100644
--- a/tests/auto/gui/kernel/qguimetatype/tst_qguimetatype.cpp
+++ b/tests/auto/gui/kernel/qguimetatype/tst_qguimetatype.cpp
@@ -87,6 +87,20 @@ private slots:
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 {};