Boost :: shared_ptr, one atomic increment in ctor, but two atomic decrements in dtor?

I go through the source code for boost::shared_ptr, and when building the control counter causes an atomic increment once. However, upon destruction, I see that the atomic decrement is called twice, connected to a weak link?

However, how does it work? One increment in the construction of another two decrements of destruction, once in release()and again in weak_release()?

+4
source share
2 answers

shared_ptr . weak_ptr. , weak_ptr shared_ptr shared_ptr ( ), weak_ptr shared_ptr.

+3

shared_ptr - , shared_ptr . 2 . , shared_ptr weak_ptr, shared_ptr ctor, .

+1

All Articles