Boost logo

Boost Users :

Subject: Re: [Boost-users] [shared_ptr] Is it possible for a shared_ptr to hand over it ownership
From: Benjamin Lau (blwy10v_at_[hidden])
Date: 2008-12-25 10:40:46


Have you tried using auto_ptr? It forces the right-hand side of the
assignment to give up ownership.

boost::shared_ptr<A> p1(new A());
std::auto_ptr<A> p2;

p2 = p1; //p1 is now null and p2 points to what p1 was pointing to

Hope this works! I haven't tested this and my C++/Boost/STL is very
shaky due to disuse.

Ben


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net