title: Map with multiple keys in C++
body: <p>I want to store data by both, their name and their index. In other words, I want to map <code>string</code> names to objects and also give them a custom order.</p>
  
  <p>What I came up with first is a <code>std::vector</code> of pairs of the <code>string</code> key and the object. The order was given by the position in the vector.</p>
  
  <pre><code>std::vector&lt;std::pair&lt;std::string, object&gt; &gt;
  </code></pre>
  
  <p>But this approach seems to be suboptimal since it doesn't automatically check for the uniqueness of <code>string</code> names. Moreover it feels wrong to group the objects by their order first, because logically their first order distinction is the name.</p>
  
  <p>I need a data structure that allows access by both name and index.</p>
  
  <pre><code>std::magic&lt;std::string, unsigned int, object&gt; collection;
  
  // access by either string or unsigned int key
  collection.insert("name", 42, new object());
  collection["name"]
  collection[42]
  </code></pre>
  
  <p>Is there a data structure for this use case already? If not, how can I put one together, preferably using the standard library? Also I would like a way to insert new elements at the position after a given element without moving all further elements around.</p>