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>
This commit is contained in:
Giuseppe D'Angelo 2015-04-11 13:14:36 +02:00
parent 11bd02e4c2
commit 16c32710bc

View File

@ -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
{