title: container with both unique elements and access by index
body: <p><strong>It seemed unclear what exactly I wanted, so I reworded the question</strong></p>
  
  <p>There are containers where each element is unique (e.g. <a href="http://www.cplusplus.com/reference/set/set/" rel="nofollow">set</a>, <a href="http://www.cplusplus.com/reference/map/map/" rel="nofollow">map</a>), however with those I am unable to access elements by index (e.g. get a single object out of the container), like this:  </p>
  
  <pre><code>std::set&lt;Object&gt; set {obj1, obj2};
  Object o = set[0]; // does not work
  </code></pre>
  
  <p>So to have a container with access by index capabilities (e.g. <a href="http://www.cplusplus.com/reference/vector/vector/" rel="nofollow">vector</a>) that only stores unique elements, I have to manually make sure that all elements within the container are unique, like this:  </p>
  
  <pre><code>std::vector&lt;Object&gt; vec { ... }; // vector with some objects
  // adding an object
  if (std::count(vec.begin(), vec.end(), obj) == 0) {
      vec.push_back(obj);
  } else {
      std::cout &lt;&lt; "object already in container!\n";
  }
  </code></pre>
  
  <p>Surely traversing the whole container each time I add an object can be expensive, so I am wondering if there is a better solution.</p>