From e083d253950d3e7ce1e6363cd29fba416e69e371 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 20 Jul 2012 15:46:40 +0200 Subject: QMetaTypeId2::IsBuiltIn: (new) template meta-function to check for built-in types MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Stephen Kelly Reviewed-by: Jędrzej Nowacki --- tests/auto/gui/kernel/qguimetatype/tst_qguimetatype.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tests/auto/gui/kernel/qguimetatype/tst_qguimetatype.cpp') 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 + struct static_assert_trigger { + Q_STATIC_ASSERT(( QMetaTypeId2::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 >::IsBuiltIn)); +Q_STATIC_ASSERT((!QMetaTypeId2 >::IsBuiltIn)); + template struct MetaEnumToType {}; -- cgit v1.2.3