- /**
- Makes the RefPtr release its reference of the data. Note that if there are
- other RefPtrs left with the same data, it might still get deleted
- automatically.
- */
- T *release()
- {
- T *d=data;
- data=0;
- decref();
- count=0;
- return d;
- }
+ RefPtr &operator=(T *);
+
+ // Likewise for the assignment operator
+ RefPtr &operator=(const RefPtr &p) { return assign(p); }
+
+ template<typename U>
+ RefPtr &operator=(const RefPtr<U> &p) { return assign(p); }
+
+ template<typename U>
+ RefPtr &operator=(const WeakPtr<U> &p) { return assign(RefPtr(p)); }
+
+private:
+ template<typename U>
+ RefPtr &assign(const RefPtr<U> &);
+
+public:
+ /** Makes the RefPtr release its reference of the data without deleting it.
+ Note that if there are other RefPtrs left with the same data, it might
+ still get deleted automatically. */
+ T *release();
+
+ /** Marks the data to not be deleted. This affects all RefPtrs with the
+ same data. */
+ void keep() { if(counts) counts->count |= RefCounts::KEEP; }