summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/tools/qsharedpointer.cpp29
-rw-r--r--src/corelib/tools/qsharedpointer.h5
-rw-r--r--src/corelib/tools/qsharedpointer_impl.h7
3 files changed, 41 insertions, 0 deletions
diff --git a/src/corelib/tools/qsharedpointer.cpp b/src/corelib/tools/qsharedpointer.cpp
index 58c62f0a3e..50e555d968 100644
--- a/src/corelib/tools/qsharedpointer.cpp
+++ b/src/corelib/tools/qsharedpointer.cpp
@@ -698,6 +698,35 @@
*/
/*!
+ \fn void QSharedPointer::reset()
+ \since 5.0
+
+ Same as clear(). For std::shared_ptr compatibility.
+*/
+
+/*!
+ \fn void QSharedPointer::reset(T *t)
+ \since 5.0
+
+ Resets this QSharedPointer object to point to \a t
+ instead. Equivalent to:
+ \code
+ QSharedPointer<T> other(t); this->swap(other);
+ \endcode
+*/
+
+/*!
+ \fn void QSharedPointer::reset(T *t, Deleter deleter)
+ \since 5.0
+
+ Resets this QSharedPointer object to point to \a t
+ instead, with deleter \a deleter. Equivalent to:
+ \code
+ QSharedPointer<T> other(t, deleter); this->swap(other);
+ \endcode
+*/
+
+/*!
\fn QWeakPointer::QWeakPointer()
Creates a QWeakPointer that points to nothing.
diff --git a/src/corelib/tools/qsharedpointer.h b/src/corelib/tools/qsharedpointer.h
index 4033b5d422..b0a1b7619d 100644
--- a/src/corelib/tools/qsharedpointer.h
+++ b/src/corelib/tools/qsharedpointer.h
@@ -85,6 +85,11 @@ public:
void clear();
+ void reset();
+ void reset(T *t);
+ template <typename Deleter>
+ void reset(T *t, Deleter deleter);
+
// casts:
template <class X> QSharedPointer<X> staticCast() const;
template <class X> QSharedPointer<X> dynamicCast() const;
diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h
index 81ce17889e..fadb4e0586 100644
--- a/src/corelib/tools/qsharedpointer_impl.h
+++ b/src/corelib/tools/qsharedpointer_impl.h
@@ -510,6 +510,13 @@ public:
inline void swap(QSharedPointer &other)
{ QSharedPointer<T>::internalSwap(other); }
+ inline void reset() { clear(); }
+ inline void reset(T *t)
+ { QSharedPointer copy(t); swap(copy); }
+ template <typename Deleter>
+ inline void reset(T *t, Deleter deleter)
+ { QSharedPointer copy(t, deleter); swap(copy); }
+
template <class X>
QSharedPointer<X> staticCast() const
{