Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-04-10 09:50:15

From: "Markus Schöpflin" <markus.schoepflin_at_[hidden]>
> Thanks a lot!
> Did you add a test for this? Something along the lines of
> boost::shared_ptr<int> p_i;
> p_i = new int(42);
> BOOST_TEST(p_i.get() != 0);

No, this shouldn't compile. If it does, it's a(nother) bug. :-) The correct
way to reassign a shared_ptr is

p_i.reset( new int(42) );

or (if you have a coding standard in place that prohibits 'new' outside of
shared_ptr constructors)

shared_ptr<int> p42( new int(42) );
p_i = p42;

Boost list run by bdawes at, gregod at, cpdaniel at, john at