From 02f6b21bbc4f1f7afc30a87227c3a0787a5d2225 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Thu, 23 Apr 2015 12:02:40 +0200 Subject: QMetaType: Fix compilation with non default constructible Q_GADGET Do not try to automatically register the meta type for Q_GADGET that are not default constructible. This fixes a source incompatibility in the function pointer syntax of QObject::connect when such types are used as an argument of a signal. Task-number: QTBUG-45721 Change-Id: I3065f6d57bc1f37e16988d2dee99118de250ca56 Reviewed-by: Thiago Macieira --- src/corelib/global/qtypetraits.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/corelib/global') diff --git a/src/corelib/global/qtypetraits.h b/src/corelib/global/qtypetraits.h index 3a305713e6..488e257e0f 100644 --- a/src/corelib/global/qtypetraits.h +++ b/src/corelib/global/qtypetraits.h @@ -506,6 +506,27 @@ Q_STATIC_ASSERT((!is_unsigned::value)); Q_STATIC_ASSERT((!is_signed::value)); Q_STATIC_ASSERT(( is_signed::value)); +template struct is_default_constructible; + +template<> struct is_default_constructible +{ +protected: + template struct test { typedef char type; }; +public: + static bool const value = false; +}; +template<> struct is_default_constructible<>::test { typedef double type; }; + +template struct is_default_constructible : is_default_constructible<> +{ +private: + template static typename test::type sfinae(U*); + template static char sfinae(...); +public: + static bool const value = sizeof(sfinae(0)) > 1; +}; + + } // namespace QtPrivate QT_END_NAMESPACE -- cgit v1.2.3