title: candidate function not viable: 1st argument ('const Node *') would lose const qualifier
body: <p>I am writing a DiGraph (directed graph) class with the c++ built in <code>unordered_map&lt;Node*, unordered_set&lt;Edge&gt;&gt;</code> data structure, where Node and Edge are two structs I defined myself. And in the class I wrote a <code>containsNode()</code> method to search if a <code>Node</code> is in the graph. This is the <code>containsNode()</code> method body:</p>
  
  <pre><code>bool DiGraph::containsNode(const Node * n) const {
      auto::const_iterator it = digraph.find(n);
      return (it == digraph.end());
  }
  </code></pre>
  
  <p><code>digraph</code> is the private member of DiGraph of type <code>unordered_map&lt;Node*, unordered_set&lt;Edge&gt;&gt;</code>.</p>
  
  <p>However, the compiler generates the following error:</p>
  
  <pre><code>error: no matching member function for call to 'find'
  auto::const_iterator it = digraph.find(n);
  candidate function not viable: 1st argument ('const Node *') would lose const qualifier
  const_iterator find(const key_type&amp; __k) const {return __t...
  </code></pre>
  
  <p>However, if I declare the method as 
  <code>bool DiGraph::containsNode(Node* n) const {...}</code> (the only difference being that the <code>const</code> keyword removed from the argument list) then there is no compilation error.</p>
  
  <p>I checked the C++ documentation and saw that the <code>find()</code> method declaration in the <code>unordered_map</code> container has the <code>const</code> keyword:</p>
  
  <pre><code>std::unordered_map::find
      const_iterator find(const Key&amp; key) const;
  </code></pre>
  
  <p>Therefore I think there shouldn't be a compilation error, so why do I get one?   </p>