title: Hash Not Defined for Class Reference?
body: <p>I have a funny error occuring where I have a custom class I am using as keys in a <code>std::unordered_map</code>. I have implemented a hash function for this custom class.</p>
  
  <p>If I create an <code>std::unordered_map</code> like so everything runs fine:</p>
  
  <pre><code>std::unordered_map &lt;Component, int&gt; myMap;
  </code></pre>
  
  <p>But if I create a <code>std::unordered_map</code> where the keys are references it complains there is no implemented hash function for this type:</p>
  
  <pre><code>std::unordered_map &lt;Component&amp;, int&gt; myMap; 
  </code></pre>
  
  <blockquote>
    <p>Error 3   error C2338: The C++ Standard doesn't provide a hash for this type. </p>
  </blockquote>
  
  <p>Any idea how I can get this to work?</p>
  
  <pre><code>class Component
  {
  public:
      GUID id;
  
      Component()
      { 
          generateGUID(&amp;id);
      }
  
      bool operator== (const Component&amp; other) const
      {
          return compareGUID(id, other.id);
      }
  };
  
  namespace std
  {
      template&lt;&gt;
      struct hash&lt;Component&gt;
      {
          std::size_t operator()(const Component&amp; cmp) const
          {
              using std::size_t;
              using std::hash;
  
              return hash&lt;GUID&gt;()(cmp.id); // GUID hash has also been implemented
          }
      };
  }
  
  
  std::unordered_map&lt;Component, int&gt; cMap1;  // compiles ok
  std::unordered_map&lt;Component&amp;, int&gt; cMap2;  // causes compiler error
  </code></pre>