+ // 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); }
+
+ ~RefPtr() { decref(); }
+
+ /**
+ 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;
+ }
+
+ /**
+ Marks the data to not be deleted. This affects all RefPtrs with the same
+ data.
+ */
+ void keep()
+ {
+ if(count)
+ *count |= KEEP;
+ }
+
+ T *get() const { return data; }
+ T &operator*() const { return *data; }