title: How to insert an rvalue into map after calling a function on it
body: <p>I'm trying to use a <code>std::unordered_map&lt;std::string, std::shared_ptr&lt;CObject&gt;&gt;</code> (hereby referred to as map) to be able to use the map for calling the same functions on different objects based on their name. Function pointers within the map would be one way to do it, but I thought it'd be cleaner to save the objects themselves in the map.</p>
  
  <p>Now, the objects are stored in a <code>shared_ptr</code>, since they have dependencies from other usages (member functions automatically called before function calls, etc), and the <code>shared_ptr</code> are allocated using a function that wraps <code>make_shared</code>, which among other thing resets it, as well as catches and throws exceptions with added relevant information (probably not needed anymore, but it's a rather large code base, and it's a part of the coding standard). This function allocates the given objects by taking the <code>shared_ptr</code> as a reference, and returns void.</p>
  
  <p>What I wanted to do was create a map with keys mapping to objects, and call the allocate function on all those objects. But since the allocate function does not return an OutputIterator or anything like it, I'm unable to use an <code>std::inserter</code>.</p>
  
  <p>They way I don't want to do it is using lvalues, like:</p>
  
  <pre><code>std::map&lt;std::string, std::shared_ptr&lt;CObject&gt;&gt; objectMap;
  shared_ptr&lt; CObject&gt; object;
  allocate&lt; CObject&gt;( object );
  objectMap.insert( make_pair("FirstObject", object ) );
  </code></pre>
  
  <p>The only way I've come up with is to call the allocate function on non-existing values on the map, as <code>map</code> would automatically create the objects for me if they don't exist. Like:</p>
  
  <pre><code>std::map&lt;std::string, std::shared_ptr&lt;CObject&gt;&gt; objectMap;
  allocate&lt; CObject&gt;( objectMap["FirstObject"] );
  </code></pre>
  
  <p>Any other ideas?</p>