title: boost::shared_ptr semantics (copying)
body: <p>I just wanted to have a fresh pair of eyes that the below code is correct in that:</p>
  
  <p>The pointers contained in the object trifoo (stored in a ptr_vector) are the shared pointers f, g, h.</p>
  
  <p>Also, what is the result of the shared_ptr copy in the constructor of trifoo; is this the correct method of 'sharing' shared_ptr, ensuring reference counts are increased etc. All my other doubts I was able to test to verify, but I'm not sure how I can check this (properly). Any critique is welcome also.</p>
  
  <pre><code>#include &lt;boost/ptr_container/ptr_vector.hpp&gt;
  #include &lt;boost/shared_ptr.hpp&gt;
  
  class foo {
      int a, b;
  public:
      foo(int A, int B) : a(A), b(B) {}
  };
  
  typedef boost::shared_ptr&lt;foo&gt; foo_ptr;
  
  class trifoo {
      foo_ptr c, d, e;
  public:
      trifoo(const foo_ptr&amp; C, const foo_ptr&amp; D, const foo_ptr&amp; E) : c(C), d(D), e(E) {}
  };
  
  int main() {
      for (int i = 0; i &lt; 5000000; i++) {
          foo_ptr f(new foo(1,2));
          foo_ptr g(new foo(2,3));
          foo_ptr h(new foo(4,5));
  
          boost::ptr_vector&lt;trifoo&gt; tris;
  
          tris.push_back(new trifoo(f, g, h));
      }
  
      return 0;
  }
  </code></pre>
  
  <p>Note: the pointless loop was to test memory leaks, of which none occurred.</p>