title: How to implement std::hash for a template class
body: <p>I have a template class looking like this:</p>
  
  <pre><code>template &lt;int N, class TypeId&gt; class Indexer {
  ...
  }
  </code></pre>
  
  <p>and I want to use it in <code>std::unordered_map</code>, I need a hash function.
  In the codebase we already had something similar (but on an untemplated class) so I tried to do it like this:</p>
  
  <pre><code>namespace std {
  template &lt;int N, class TypeId&gt;
  struct hash&lt;Indexer&lt;N, TypeId&gt; &gt; {
      size_t operator()(const Indexer&lt;N, TypeId&gt;&amp; id) const noexcept {
          ...
      }
  };
  }
  </code></pre>
  
  <p>It is also quite similar to <a href="https://stackoverflow.com/questions/16451198/c-stdtr1hash-for-a-templated-class">another answer</a>.
  Unfortunately this does not work, just gives a bunch of unhelpfull errors. Any insights?</p>