title: Implementing a C++ hashtable class using template
body: <p>I am trying to implement a hashtable in C++ that sort of like the Java version</p>
  
  <p>I would like it has the form of </p>
  
  <pre><code>template &lt;class Key, class Value&gt; 
  class hashtable {
  ...
  }
  </code></pre>
  
  <p>Soon enough I notice that I need to somehow convert Key into a number, so that I can use the simple hash function  </p>
  
  <pre><code>int h(int hashkey) { 
      return hashkey%some_prime;
  }
  </code></pre>
  
  <p>But the headache is, Key type is only known at run time. Is it possible to check what type Key is on run time in C++. Or I have to create this hashtable class with different type manually? That is easier to do but ugly. Anyone know an elegant solution?</p>