title: How to handle a map of shared_ptr with move constructor correctly?
body: <p>Consider I have a container <code>std::map&lt;int, std::shared_ptr&lt;MyClass&gt;&gt;</code> and I want to fill it in external function and avoid coping of its contents. So I have</p>
  
  <pre><code>typedef Container std::map&lt;int, std::shared_ptr&lt;MyClass&gt;&gt;
  
  Container&amp;&amp; f(){
      Container bar;
      auto foo = std::shared_ptr&lt;MyClass&gt;(new MyClass());
      bar.insert(std::make_pair(0,foo));
      std::cout&lt;&lt;bar.at(1)-&gt;print_smth&lt;&lt;'\n'; //This works
      return std::move(bar);
  }
  
  int main(){
      Container baz(f());
      std::cout&lt;&lt;bar.at(1)-&gt;print_smth&lt;&lt;'\n'; //This doesn't
      // Container baz has element 1, but shared_ptr is invalidated, because it has 0 references.
  
  }
  </code></pre>
  
  <p>If I use conventional copy constructor everything works as expected.</p>