QSharedPointer/QWeakPointer: clean up class definition
Remove superfluous class template arguments (<T>). Qualify one member function call with this-> instead of QSharedPointer<T>::. Change-Id: I5cbe8776fc914138b7ceb4747a08c6475227197b Reviewed-by: Olivier Goffart <ogoffart@woboq.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
ad5f6d4326
commit
98d7d4c1e5
@ -318,9 +318,9 @@ public:
|
|||||||
inline QSharedPointer(T *ptr, Deleter deleter) : value(ptr) // throws
|
inline QSharedPointer(T *ptr, Deleter deleter) : value(ptr) // throws
|
||||||
{ internalConstruct(ptr, deleter); }
|
{ internalConstruct(ptr, deleter); }
|
||||||
|
|
||||||
inline QSharedPointer(const QSharedPointer<T> &other) : value(other.value), d(other.d)
|
inline QSharedPointer(const QSharedPointer &other) : value(other.value), d(other.d)
|
||||||
{ if (d) ref(); }
|
{ if (d) ref(); }
|
||||||
inline QSharedPointer<T> &operator=(const QSharedPointer<T> &other)
|
inline QSharedPointer &operator=(const QSharedPointer &other)
|
||||||
{
|
{
|
||||||
QSharedPointer copy(other);
|
QSharedPointer copy(other);
|
||||||
swap(copy);
|
swap(copy);
|
||||||
@ -333,7 +333,7 @@ public:
|
|||||||
other.d = 0;
|
other.d = 0;
|
||||||
other.value = 0;
|
other.value = 0;
|
||||||
}
|
}
|
||||||
inline QSharedPointer<T> &operator=(QSharedPointer<T> &&other)
|
inline QSharedPointer &operator=(QSharedPointer &&other)
|
||||||
{
|
{
|
||||||
swap(other);
|
swap(other);
|
||||||
return *this;
|
return *this;
|
||||||
@ -345,7 +345,7 @@ public:
|
|||||||
{ if (d) ref(); }
|
{ if (d) ref(); }
|
||||||
|
|
||||||
template <class X>
|
template <class X>
|
||||||
inline QSharedPointer<T> &operator=(const QSharedPointer<X> &other)
|
inline QSharedPointer &operator=(const QSharedPointer<X> &other)
|
||||||
{
|
{
|
||||||
QSHAREDPOINTER_VERIFY_AUTO_CAST(T, X); // if you get an error in this line, the cast is invalid
|
QSHAREDPOINTER_VERIFY_AUTO_CAST(T, X); // if you get an error in this line, the cast is invalid
|
||||||
internalCopy(other);
|
internalCopy(other);
|
||||||
@ -361,7 +361,7 @@ public:
|
|||||||
{ internalSet(other.d, other.value); return *this; }
|
{ internalSet(other.d, other.value); return *this; }
|
||||||
|
|
||||||
inline void swap(QSharedPointer &other)
|
inline void swap(QSharedPointer &other)
|
||||||
{ QSharedPointer<T>::internalSwap(other); }
|
{ this->internalSwap(other); }
|
||||||
|
|
||||||
inline void reset() { clear(); }
|
inline void reset() { clear(); }
|
||||||
inline void reset(T *t)
|
inline void reset(T *t)
|
||||||
@ -402,7 +402,7 @@ public:
|
|||||||
|
|
||||||
#if defined(Q_COMPILER_RVALUE_REFS) && defined(Q_COMPILER_VARIADIC_TEMPLATES)
|
#if defined(Q_COMPILER_RVALUE_REFS) && defined(Q_COMPILER_VARIADIC_TEMPLATES)
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
static QSharedPointer<T> create(Args && ...arguments)
|
static QSharedPointer create(Args && ...arguments)
|
||||||
{
|
{
|
||||||
typedef QtSharedPointer::ExternalRefCountWithContiguousData<T> Private;
|
typedef QtSharedPointer::ExternalRefCountWithContiguousData<T> Private;
|
||||||
# ifdef QT_SHAREDPOINTER_TRACK_POINTERS
|
# ifdef QT_SHAREDPOINTER_TRACK_POINTERS
|
||||||
@ -410,7 +410,7 @@ public:
|
|||||||
# else
|
# else
|
||||||
typename Private::DestroyerFn destroy = &Private::deleter;
|
typename Private::DestroyerFn destroy = &Private::deleter;
|
||||||
# endif
|
# endif
|
||||||
QSharedPointer<T> result(Qt::Uninitialized);
|
QSharedPointer result(Qt::Uninitialized);
|
||||||
result.d = Private::create(&result.value, destroy);
|
result.d = Private::create(&result.value, destroy);
|
||||||
|
|
||||||
// now initialize the data
|
// now initialize the data
|
||||||
@ -422,7 +422,7 @@ public:
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
static inline QSharedPointer<T> create()
|
static inline QSharedPointer create()
|
||||||
{
|
{
|
||||||
typedef QtSharedPointer::ExternalRefCountWithContiguousData<T> Private;
|
typedef QtSharedPointer::ExternalRefCountWithContiguousData<T> Private;
|
||||||
# ifdef QT_SHAREDPOINTER_TRACK_POINTERS
|
# ifdef QT_SHAREDPOINTER_TRACK_POINTERS
|
||||||
@ -430,7 +430,7 @@ public:
|
|||||||
# else
|
# else
|
||||||
typename Private::DestroyerFn destroy = &Private::deleter;
|
typename Private::DestroyerFn destroy = &Private::deleter;
|
||||||
# endif
|
# endif
|
||||||
QSharedPointer<T> result(Qt::Uninitialized);
|
QSharedPointer result(Qt::Uninitialized);
|
||||||
result.d = Private::create(&result.value, destroy);
|
result.d = Private::create(&result.value, destroy);
|
||||||
|
|
||||||
// now initialize the data
|
// now initialize the data
|
||||||
@ -579,9 +579,9 @@ public:
|
|||||||
{ return *this = QWeakPointer(ptr); }
|
{ return *this = QWeakPointer(ptr); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
inline QWeakPointer(const QWeakPointer<T> &o) : d(o.d), value(o.value)
|
inline QWeakPointer(const QWeakPointer &o) : d(o.d), value(o.value)
|
||||||
{ if (d) d->weakref.ref(); }
|
{ if (d) d->weakref.ref(); }
|
||||||
inline QWeakPointer<T> &operator=(const QWeakPointer<T> &o)
|
inline QWeakPointer &operator=(const QWeakPointer &o)
|
||||||
{
|
{
|
||||||
internalSet(o.d, o.value);
|
internalSet(o.d, o.value);
|
||||||
return *this;
|
return *this;
|
||||||
@ -589,7 +589,7 @@ public:
|
|||||||
|
|
||||||
inline QWeakPointer(const QSharedPointer<T> &o) : d(o.d), value(o.data())
|
inline QWeakPointer(const QSharedPointer<T> &o) : d(o.d), value(o.data())
|
||||||
{ if (d) d->weakref.ref();}
|
{ if (d) d->weakref.ref();}
|
||||||
inline QWeakPointer<T> &operator=(const QSharedPointer<T> &o)
|
inline QWeakPointer &operator=(const QSharedPointer<T> &o)
|
||||||
{
|
{
|
||||||
internalSet(o.d, o.value);
|
internalSet(o.d, o.value);
|
||||||
return *this;
|
return *this;
|
||||||
@ -600,7 +600,7 @@ public:
|
|||||||
{ *this = o; }
|
{ *this = o; }
|
||||||
|
|
||||||
template <class X>
|
template <class X>
|
||||||
inline QWeakPointer<T> &operator=(const QWeakPointer<X> &o)
|
inline QWeakPointer &operator=(const QWeakPointer<X> &o)
|
||||||
{
|
{
|
||||||
// conversion between X and T could require access to the virtual table
|
// conversion between X and T could require access to the virtual table
|
||||||
// so force the operation to go through QSharedPointer
|
// so force the operation to go through QSharedPointer
|
||||||
@ -621,7 +621,7 @@ public:
|
|||||||
{ *this = o; }
|
{ *this = o; }
|
||||||
|
|
||||||
template <class X>
|
template <class X>
|
||||||
inline QWeakPointer<T> &operator=(const QSharedPointer<X> &o)
|
inline QWeakPointer &operator=(const QSharedPointer<X> &o)
|
||||||
{
|
{
|
||||||
QSHAREDPOINTER_VERIFY_AUTO_CAST(T, X); // if you get an error in this line, the cast is invalid
|
QSHAREDPOINTER_VERIFY_AUTO_CAST(T, X); // if you get an error in this line, the cast is invalid
|
||||||
internalSet(o.d, o.data());
|
internalSet(o.d, o.data());
|
||||||
@ -636,7 +636,7 @@ public:
|
|||||||
inline bool operator!=(const QSharedPointer<X> &o) const
|
inline bool operator!=(const QSharedPointer<X> &o) const
|
||||||
{ return !(*this == o); }
|
{ return !(*this == o); }
|
||||||
|
|
||||||
inline void clear() { *this = QWeakPointer<T>(); }
|
inline void clear() { *this = QWeakPointer(); }
|
||||||
|
|
||||||
inline QSharedPointer<T> toStrongRef() const { return QSharedPointer<T>(*this); }
|
inline QSharedPointer<T> toStrongRef() const { return QSharedPointer<T>(*this); }
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user