title: how to adapt an unordered STL container to store only Values of a Key-Value pair?
body: <p>The new C++11 standard has unordered containers. In particular, the <code>std::unordered_map&lt;Key, Value&gt;</code> stores a <code>std::pair&lt;Key, Value&gt;</code> in a location based on <code>std::hash&lt;Key&gt;</code> (default hash function). Similarly, the <code>std::unordered_set&lt;Key&gt;</code> stores a Key in a location based on <code>std::hash&lt;Key&gt;</code>. </p>
  
  <p>My question is: how can one store <strong>only</strong> the Value of a Key-Value pair, in a location based on <code>std::hash&lt;Key&gt;</code>? This would be useful if one uses a <strong>perfect hash function</strong>, i.e. one for which different Keys map to different hash indices (so there is never collision resolution required).</p>
  
  <p>An unordered_set only uses the key, and an unordered_map uses both the key and the value, so the unordered STL containers in the new C++11 standard do not seem to allow such customization. What would be a good way to get such a data structure from the existing STL containers? </p>
  
  <p>More generally, how can one store a <code>std::pair&lt;T, Value&gt;</code> in a location based on <code>std::hash&lt;Key&gt;</code>, where <code>T</code> is a type representing a signature of the Key? E.g. if Key is a large data structure, I would like to compute a 64-bit hash key and split this into two 32 bit parts: the upper 32 bits together with the Value form a <code>std::pair&lt;uint32_t, Value&gt;</code>, and the lower 32 bits determine the location where this pair is stored.</p>
  
  <p>An application where this would be useful is e.g. computer chess, where a position (several kilobytes in some programs) as the Key type is hashed into a 64-bit key, of which only the upper 32 bits and some search related information as the Value type are stored as a <code>std::pair</code> (usually only 16 bytes in total) in a location based on the lower 32 bits of the hash key. </p>