title: How to use stdext::hash_map where the key is a custom object?
body: <p>Using the STL C++ hash_map...</p>
  
  <pre><code>class MyKeyObject
  {
      std::string str1;
      std::string str2;
  
      bool operator==(...) { this.str1 == that.str1 ... }
  };
  
  class MyData
  {
      std::string data1;
      int data2;
      std::string etcetc;
  };
  </code></pre>
  
  <p>like this...</p>
  
  <pre><code>MyKeyObject a = MyKeyObject(...);
  MyData b = MyData(...);
  
  stdext::hash_map &lt;MyKeyObject, MyData&gt; _myDataHashMap;
  _myDataHashMap[ a ] = b;
  </code></pre>
  
  <p>I get a whole load of errors. Here are the first three...</p>
  
  <blockquote>
    <p>Error 1   error C2784: 'bool
    std::operator &lt;(const
    std::_Tree&lt;_Traits> &amp;,const
    std::_Tree&lt;_Traits> &amp;)' : could not
    deduce template argument for 'const
    std::_Tree&lt;_Traits> &amp;' from 'const
    MyKeyObject'  c:\program files\microsoft
    visual studio
    8\vc\include\functional   143</p>
    
    <p>Error 2   error C2784: 'bool
    std::operator &lt;(const
    std::basic_string&lt;_Elem,_Traits,_Alloc>
    &amp;,const _Elem *)' : could not deduce
    template argument for 'const
    std::basic_string&lt;_Elem,_Traits,_Alloc>
    &amp;' from 'const
    Tasking::MyKeyObject' c:\program
    files\microsoft visual studio
    8\vc\include\functional   143</p>
    
    <p>Error 3   error C2784: 'bool
    std::operator &lt;(const _Elem *,const
    std::basic_string&lt;_Elem,_Traits,_Alloc>
    &amp;)' : could not deduce template
    argument for 'const _Elem *' from
    'const MyDataObject'  c:\program
    files\microsoft visual studio
    8\vc\include\functional   143</p>
    
    <p>...</p>
  </blockquote>
  
  <p>If I set the key to something simple like an int all is well. </p>
  
  <p>What am I doing wrong?! Maybe I need to do something with templates? </p>
  
  <p>Is there a better (quicker?) way of accessing data using a custom key object like this?</p>