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:
parent
11bd02e4c2
commit
16c32710bc
@ -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
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user