title: Shared argument in constructor initializer list
body: <p>I have this classes:</p>
  
  <pre><code>class A
  {
  public:
      A(std::shared_ptr&lt;SomeClass&gt; p);
  private:
      std::shared_ptr&lt;SomeClass&gt; _p;
  };
  
  class B
  {
  public:
      B(std::shared_ptr&lt;SomeClass&gt; p);
  private:
      std::shared_ptr&lt;SomeClass&gt; _p;
  };
  
  class Foo
  {
  public:
      Foo();
  private:
      A _a;
      B _b;
  };
  </code></pre>
  
  <p>Both constructor arguments from <code>A</code> and <code>B</code> share the same pointer reference <code>shared_ptr</code>. In this case:</p>
  
  <ul>
  <li><p>How would be the best way of initializing <code>Foo</code>? </p></li>
  <li><p>Is it still possible to use a initialization list in <code>Foo</code>s constructor?</p></li>
  </ul>
  
  <p>I am confused, because since both classes need the same <code>shared_ptr</code>instance, I would have to store that pointer somewhere, and I don't think that is possible with initialization lists.</p>
  
  <p>Also, if the initialization occurs in the body of the constructor, it implies that both <code>A</code> and <code>B</code> should have a <code>move</code> constructor, correct? Because I would have to do something like this:</p>
  
  <pre><code>Foo::Foo() //: Cannot use initializer list
  {
      auto ptr = std::make_shared&lt;SomeClass&gt;(SomeClass());
      _a = A(ptr);
      _b = B(ptr);
  }
  </code></pre>