title: Boost shared_ptr use_count function
body: <p>My application problem is the following -</p>
  
  <p>I have a large structure foo.  Because these are large and for memory management reasons, we do not wish to delete them when processing on the data is complete.  </p>
  
  <p>We are storing them in <code>std::vector&lt;boost::shared_ptr&lt;foo&gt;&gt;.</code></p>
  
  <p>My question is related to knowing when all processing is complete.  First decision is that we do not want any of the other application code to mark a complete flag in the structure because there are multiple execution paths in the program and we cannot predict which one is the last.  </p>
  
  <p>So in our implementation, once processing is complete, we delete all copies of <code>boost::shared_ptr&lt;foo&gt;&gt;</code> except for the one in the vector.  This will drop the reference counter in the shared_ptr to 1.  Is it practical to use shared_ptr.use_count() to see if it is equal to 1 to know when all other parts of my app are done with the data.</p>
  
  <p>One additional reason I'm asking the question is that the boost documentation on the shared pointer <a href="http://www.boost.org/doc/libs/1_42_0/libs/smart_ptr/shared_ptr.htm" rel="nofollow noreferrer">shared_ptr</a> recommends not using "use_count" for production code.</p>
  
  <hr>
  
  <p>Edit - 
  What I did not say is that when we need a new foo, we will scan the vector of foo pointers looking for a foo that is not currently in use and use that foo for the next round of processing.  This is why I was thinking that having the reference counter of 1 would be a safe way to ensure that this particular foo object is no longer in use.</p>