title: How do I insert a element into a std::unordered_map<int, vector<Object*>>
body: <p>I'm trying to create a hash of arrays of pointers to my object.</p>
  <p>The hash key is an int for the type of the object, and the array is a list of the objects to render.</p>
  <p>What I'm trying to do is :</p>
  <pre><code>unordered_map&lt;int, vector&lt;Object*&gt; &gt; drawQueue;
  drawQueue.clear(); // new empty draw queue
  
  for ( ... ) {
     drawQueue.at(type).push_back(my_obj);
  }
   
  </code></pre>
  <p>So I'm not familiar enough with the nuances of the STL stuff, since I get an exception saying out_of_bounds, which is what happens when the key doesn't exist.</p>
  <p>So I figured I need to create the key first, and then add to the vector :</p>
  <pre><code>if (drawQueue.count(type)) {
      // key already exists
      drawQueue.at(type).push_back(my_obj);
  } else {
      //key doesn't exist
      drawQueue.insert(type, vector&lt;Object*&gt;); // problem here
      drawQueue.at(type).push_back(my_obj);
  }
  </code></pre>
  <p>But now I'm really lost, as I don't know how to create/initialise/whatever an empty <code>vector</code> to the insert of the <code>unordered_map</code>...</p>
  <p>Or am I doing this the entirely wrong way?</p>