Re: [Boost-users] [smart_ptr] weak_ptr / shared_ptr interaction

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.
Thanks for your reply. So you're saying that the behavior of shared_ptr is correct (perfectly fine with me). But then I have to say, that the documentation of shared_ptr located under http://www.boost.org/doc/libs/1_39_0/libs/smart_ptr/shared_ptr.htm#construct... is wrong, because it says that if you construct a shared_ptr from a weak_ptr (!) the use_count will *not* change.

AMDG Alexander Heinrich wrote:
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.
Thanks for your reply. So you're saying that the behavior of shared_ptr is correct (perfectly fine with me). But then I have to say, that the documentation of shared_ptr located under http://www.boost.org/doc/libs/1_39_0/libs/smart_ptr/shared_ptr.htm#construct... is wrong, because it says that if you construct a shared_ptr from a weak_ptr (!) the use_count will *not* change.
The documentation does not say that the use count doesn't change. It says that |use_count() == r.use_count(), which is true.| In Christ, Steven Watanabe
participants (2)
-
Alexander Heinrich
-
Steven Watanabe