title: Does using .reset() on a std::shared_ptr delete all instances
body: <p>I'm new to shared_ptr's and I'm trying to figure out the exact functionality of the .reset() function. </p>
  
  <pre><code>#include &lt;memory&gt;
  #include &lt;stdio&gt;
  
  using namespace std;
  class SomeClass{};
  
  int main() 
  {
     shared_ptr&lt;SomeClass&gt; sp (nullptr);
  
     //do some stuff, sp now has 10 co-owners
  
     cout &lt;&lt; sp.use_count &lt;&lt; endl;
     sp.reset();
     cout &lt;&lt; sp.use_count &lt;&lt; endl;
     return 0;
  }
  </code></pre>
  
  <p>Would output</p>
  
  <pre><code>10
  0
  </code></pre>
  
  <p>So since I used the reset function are all instances deleted from memory? As in, have I just eliminated any possible memory leaks with sp? Obviously this was a toy example that I quickly made up, sorry if it has any errors.</p>
  
  <p>Follow up situation:</p>
  
  <pre><code>shared_ptr&lt;SomeClass&gt; returnThis() {
      shared_ptr&lt;SomeClass&gt; someObject(new SomeClass(/*default constructor for example*/) );
      return someObject;
  }
  </code></pre>
  
  <p>somehere in main:</p>
  
  <pre><code>shared_ptr&lt;SomeClass&gt; mainObject;
  mainObject = returnThis();
  </code></pre>
  
  <p>Does mainObject have a use count of 2 because someObject was created in a function but never cleared? Or is it one and the clean-up is done automatically when returning the value?</p>