summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2015-04-11 13:14:36 +0200
committerGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2015-04-11 22:09:30 +0000
commit16c32710bc8a5ecefc833352159361be564f3fe4 (patch)
tree0c383dd3834aa49ef8bb5d67c5f98fd63080c61f /src/corelib
parent11bd02e4c2f96d904c532e568089596af02e8593 (diff)
QPointer: add a static assertion to help the user when using a wrong template type
Sometimes people mistype QPointer<Foo *> when they actually must use QPointer<Foo>, add a static assertion for an improved error message (rather than the usual weird template mess). Change-Id: Ic77e3e752ac1906b94f3432eaededf0f7a2737be Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/kernel/qpointer.h3
1 files changed, 3 insertions, 0 deletions
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 <QtCore/qsharedpointer.h>
+#include <QtCore/qtypeinfo.h>
#ifndef QT_NO_QOBJECT
@@ -45,6 +46,8 @@ class QVariant;
template <class T>
class QPointer
{
+ Q_STATIC_ASSERT_X(!QtPrivate::is_pointer<T>::value, "QPointer's template type must not be a pointer type");
+
template<typename U>
struct TypeSelector
{