title: How to ignore constness in a function template?
body: <p>I have the following template function:</p>
  
  <pre><code>template&lt;typename K, typename V&gt;
  bool hasKey( const std::map&lt;K, V&gt;&amp; m, K&amp; k ) {
      return m.find(k) != m.end();
  }
  </code></pre>
  
  <p>The keys in the map are not <code>const</code>. </p>
  
  <p>Now, I may have a <code>const K</code>. How can I write a template that would allow me to pass in both <code>K and</code>const K` to the function?</p>
  
  <p>Is the solution to use a <code>const_cast</code> every time I call the function?</p>