Boost logo

Boost :

From: Darin Adler (darin_at_[hidden])
Date: 2001-10-18 10:14:45


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

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

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)
         { swap(shared_ptr(r.release())); }

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

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