From 16c32710bc8a5ecefc833352159361be564f3fe4 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Sat, 11 Apr 2015 13:14:36 +0200 Subject: [PATCH] QPointer: add a static assertion to help the user when using a wrong template type Sometimes people mistype QPointer when they actually must use QPointer, add a static assertion for an improved error message (rather than the usual weird template mess). Change-Id: Ic77e3e752ac1906b94f3432eaededf0f7a2737be Reviewed-by: Marc Mutz --- src/corelib/kernel/qpointer.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/corelib/kernel/qpointer.h b/src/corelib/kernel/qpointer.h index af7c11e4d7..07649ce0b2 100644 --- a/src/corelib/kernel/qpointer.h +++ b/src/corelib/kernel/qpointer.h @@ -35,6 +35,7 @@ #define QPOINTER_H #include +#include #ifndef QT_NO_QOBJECT @@ -45,6 +46,8 @@ class QVariant; template class QPointer { + Q_STATIC_ASSERT_X(!QtPrivate::is_pointer::value, "QPointer's template type must not be a pointer type"); + template struct TypeSelector {