- /**
- 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.
- */
+ // 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); }
+
+private:
+ template<typename U>
+ RefPtr &assign(const RefPtr<U> &p)
+ {
+ decref();
+ data = p.data;
+ counts = p.counts;
+ incref();
+ return *this;
+ }
+
+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. */