3 Jul
2009
3 Jul
'09
4:01 p.m.
At 1:55 PM +0200 7/3/09, Alexander Heinrich wrote:
Now I experienced some odd behavior with the following piece of code: <code> boost::shared_ptr<int> s1(new int(42)); // use_count == 1 boost::weak_ptr<int> w(s1); // use_count == 1 boost::shared_ptr<int> s2(w); // use_count == 2 (expected use_count == 1)
Both s1 and s2 should now have use_count of 2 at this point, since there are 2 shared_ptrs sharing ownership of the same pointee. The post-condition expression is correct; the value of r.use_count() was changed by the construction of the new shared_ptr.