title: Correct way of 'upserting' items into map<key, shared_ptr<foo>>
body: <p>I want to upsert (update or insert) items into a <code>map&lt;int,shared_ptr&lt;PortfolioEntry&gt;&gt;</code> structure. My current code is something like the following:</p>
  
  <pre><code>auto existing = positions.find(id);
  if (existing == positions.end())
  {
    positions[id] = make_shared&lt;PortfolioEntry&gt;(id, amount, price);
  }
  else
  {
    // update positions[id]
  }
  </code></pre>
  
  <p>So I'm wondering if it's the right way of doing things. Is <code>find()</code> efficient? Is assigning to <code>positions[id]</code> the right way to do this, or should I use some <code>std::move</code> construct?</p>