title: std::shared_ptr - Best practice for passing shared pointer as parameter
body: <p>I've been away from serious C++ for about ten years. I'm coming back in to the fold and am currently working on a project to fully familiarize myself with C++11. I'm having a bit of an existential crisis about how to best pass std::shared_ptr's around.</p>
  
  <p>For a simple example, take the following setup:</p>
  
  <pre><code>class ServiceB {
  public:
      ServiceB() {}
  };
  
  class ServiceA {
  public:
      ServiceA(std::shared_ptr&lt;ServiceB&gt;&amp; serviceB)
          : _serviceB(serviceB) {
  
      }
  
  private:
      std::shared_ptr&lt;ServiceB&gt; _serviceB;
  };
  
  class Root {
  public:
      Root()
          : _serviceB(std::shared_ptr&lt;ServiceB&gt;(new ServiceB())),
          _serviceA(std::unique_ptr&lt;ServiceA&gt;(new ServiceA(_serviceB))) {
  
      }
  
  private:
      std::shared_ptr&lt;ServiceB&gt; _serviceB;
      std::unique_ptr&lt;ServiceA&gt; _serviceA;
  };
  </code></pre>
  
  <p>Notice here that ServiceA requires a reference to ServiceB. I'd like to keep that reference tied up in a shared_ptr. Am I okay to do what I did here, which is simply pass the shared_ptr down as a reference and let the std::shared_ptr copy constructor do the work for me? Does this properly increment the reference count on the shared_ptr?</p>
  
  <p>If this is not the best way to do this, what is the common "best practice" for passing around std::shared_ptr's?</p>