Boost logo

Boost :

From: Darin Adler (darin_at_[hidden])
Date: 2001-10-18 10:21:03


on 10/18/01 5:15 AM, Peter Dimov at pdimov_at_[hidden] wrote:

> void reset(T * p = 0)
> {
> shared_ptr(p).swap(*this);
> }

[Lets try that again without the bugs.]

Wow. That is definitely the right solution:

   template<typename Y>
      shared_ptr& operator=(const shared_ptr<Y>& r) {
         shared_ptr copy(r);
         swap(copy);
         return *this;
      }

   template<typename Y>
      shared_ptr& operator=(std::auto_ptr<Y>& r)
         { reset(r.release()); }

   void reset(T* p=0) { shared_ptr(p).swap(*this); }

Do these look good to you?

    -- Darin


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk