title: Const correctness, std move and smart pointers
body: <p>I'm struggling to understand when should I use const smart pointers and when to move them.</p>
  
  <p>Based on the following code:</p>
  
  <pre><code>class Foo;
  class Bar;
  
  typedef std::shared_ptr&lt;Foo&gt; FooPtr;
  typedef std::shared_ptr&lt;Bar&gt; BarPtr;
  
  class Bar {
  
  };
  
  class Foo {
  public:
      static FooPtr create()
      {
          FooPtr f = std::make_shared&lt;Foo&gt;();
          f-&gt;initialize();
          return f;
      }
  
      void setData(const BarPtr&amp; b) {
          m_b = b;
      }
  private:
      BarPtr m_b;
  };
  
  inline const FooPtr&amp; internalCreateFoo(const BarPtr&amp; b)
  {
      FooPtr foo = Foo::create();
      foo-&gt;setData(b);
  
      int id = foo-&gt;getID();
      m_foos[id] = std::move(foo);
  
      return m_foos[id];
  }
  </code></pre>
  
  <p>1: is <code>std::move(foo)</code> really necessary here?</p>
  
  <p>2: what happens regarding the <code>std::move</code> if <code>foo</code> is created as a <code>const</code>, like <code>const FooPtr&amp; foo = ...</code>?</p>