title: Something unclear in this shared_ptr example
body: <pre><code>#include &lt;iostream&gt;
  #include &lt;boost/shared_ptr.hpp&gt;
  
  class implementation
  {
  public:
      ~implementation() { std::cout &lt;&lt;"destroying implementation\n"; }
      void do_something() { std::cout &lt;&lt; "did something\n"; }
  };
  
  void test()
  {
      boost::shared_ptr&lt;implementation&gt; sp1(new implementation());
      std::cout&lt;&lt;"The Sample now has "&lt;&lt;sp1.use_count()&lt;&lt;" references\n";
  
      boost::shared_ptr&lt;implementation&gt; sp2 = sp1;
      std::cout&lt;&lt;"The Sample now has "&lt;&lt;sp2.use_count()&lt;&lt;" references\n";
  
      sp1.reset();
      std::cout&lt;&lt;"After Reset sp1. The Sample now has "&lt;&lt;sp2.use_count()&lt;&lt;" references\n";
  
      sp2.reset();
      std::cout&lt;&lt;"After Reset sp2.\n";
  }
  
  int main()
  {
      test();
  }
  </code></pre>
  
  <p>The running result is below:</p>
  
  <pre><code>$ ./a.out 
  The Sample now has 1 references
  The Sample now has 2 references
  After Reset sp1. The Sample now has 1 references
  destroying implementation
  After Reset sp2.
  </code></pre>
  
  <p>Please check the above code. The first thing unclear to me is that what does below sentence mean? So sp1 is a pointer? a function? or a pointer to a function? and <code>new implementation()</code> means what? The argument of sp1()?</p>
  
  <pre><code>boost::shared_ptr&lt;implementation&gt; sp1(new implementation());
  </code></pre>
  
  <p>The second question is that <code>destroying implementation</code> is given as a result of <code>sp1.reset()</code> and <code>sp2.reset()</code>. But if <code>sp1.reset()</code> is commented out, then the result will be:</p>
  
  <pre><code>$ ./a.out 
  The Sample now has 1 references
  The Sample now has 2 references
  After Reset sp1. The Sample now has 2 references
  After Reset sp2.
  destroying implementation
  </code></pre>
  
  <p>If we only comment out <code>sp2.reset()</code>, then the result will be:</p>
  
  <pre><code>$ ./a.out 
  The Sample now has 1 references
  The Sample now has 2 references
  After Reset sp1. The Sample now has 1 references
  After Reset sp2.
  destroying implementation
  </code></pre>
  
  <p>So it is not necessary to call both <code>sp1.reset()</code> and <code>sp2.reset()</code> to release the shared_ptr, am I right?</p>