+
+ template<typename U>
+ RefPtr(const RefPtr<U> &p): data(p.data), count(p.count) { incref(); }
+
+ ~RefPtr() { decref(); }
+
+ RefPtr &operator=(T *d)
+ {
+ decref();
+ data = d;
+ count = (d ? new unsigned(1) : 0);
+ return *this;
+ }
+
+ // 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)