title: error: no matching function for call to ‘std::map<std::__cxx11::basic_string<char>
body: <p>I'm trying to delete a node for a general directed weighted graph. When I delete a node, I also need to delete the incoming and outgoing edges of that node, so I cannot just delete the node, but also have to delete the edges that are attached to other nodes that used to link to this node before it is deleted.</p>
  
  <p>For the function, I'm trying to find the linking node by using the find() function, which is used to find a node within nodes_, which is declared as:</p>
  
  <pre><code>std::map&lt; N, std::shared_ptr&lt;Node&gt; &gt; nodes_;
  </code></pre>
  
  <p>I tried originNodeOfIncomingEdge->edges_.erase(edge); but it doesn't work, so I'm trying to do the following in order to find the node on the map of nodes_ before doing an erase.</p>
  
  <pre><code>auto findLinkingNode1 = nodes_.find(originNodeOfIncomingEdge);
  </code></pre>
  
  <p>However, I keep getting the following error, not sure what is wrong.</p>
  
  <pre><code>tests/Graph.tem:558:64: error: no matching function for call to ‘std::map&lt;std::__cxx11::basic_string&lt;char&gt;, std::shared_ptr&lt;gdwg::Graph&lt;std::__cxx11::basic_string&lt;char&gt;, int&gt;::Node&gt;, std::less&lt;std::__cxx11::basic_string&lt;char&gt; &gt;, std::allocator&lt;std::pair&lt;const std::__cxx11::basic_string&lt;char&gt;, std::shared_ptr&lt;gdwg::Graph&lt;std::__cxx11::basic_string&lt;char&gt;, int&gt;::Node&gt; &gt; &gt; &gt;::find(std::shared_ptr&lt;gdwg::Graph&lt;std::__cxx11::basic_string&lt;char&gt;, int&gt;::Node&gt;&amp;)’
      auto findLinkingNode1 = nodes_.find(originNodeOfIncomingEdge);
                                                                  ^
  In file included from /usr/local/include/c++/6.1.0/map:61:0,
                   from tests/Graph.h:19,
                   from tests/test8c.cpp:3:
  /usr/local/include/c++/6.1.0/bits/stl_map.h:1079:7: note: candidate: std::map&lt;_Key, _Tp, _Compare, _Alloc&gt;::iterator std::map&lt;_Key, _Tp, _Compare, _Alloc&gt;::find(const key_type&amp;) [with _Key = std::__cxx11::basic_string&lt;char&gt;; _Tp = std::shared_ptr&lt;gdwg::Graph&lt;std::__cxx11::basic_string&lt;char&gt;, int&gt;::Node&gt;; _Compare = std::less&lt;std::__cxx11::basic_string&lt;char&gt; &gt;; _Alloc = std::allocator&lt;std::pair&lt;const std::__cxx11::basic_string&lt;char&gt;, std::shared_ptr&lt;gdwg::Graph&lt;std::__cxx11::basic_string&lt;char&gt;, int&gt;::Node&gt; &gt; &gt;; std::map&lt;_Key, _Tp, _Compare, _Alloc&gt;::iterator = std::_Rb_tree_iterator&lt;std::pair&lt;const std::__cxx11::basic_string&lt;char&gt;, std::shared_ptr&lt;gdwg::Graph&lt;std::__cxx11::basic_string&lt;char&gt;, int&gt;::Node&gt; &gt; &gt;; std::map&lt;_Key, _Tp, _Compare, _Alloc&gt;::key_type = std::__cxx11::basic_string&lt;char&gt;]
         find(const key_type&amp; __x)
         ^~~~
  </code></pre>
  
  <p>This is the code for deleteNode.</p>
  
  <pre><code>template &lt;typename N, typename E&gt;
  void Graph&lt;N, E&gt;::deleteNode(const N&amp; node) noexcept {
      auto findNode = nodes_.find(node);
      if (findNode != nodes_.end()) {
  
          for (auto edge: findNode-&gt;second-&gt;incomingEdges_) {
  
              // find the node which has incoming edges into the deleted node
              auto originNodeOfIncomingEdge = edge-&gt;dest.lock(); // origin node of incoming edge to deleted node
  
              auto nodeVal = originNodeOfIncomingEdge-&gt;val_;
              std::cout &lt;&lt; "Print out value of origin node of incoming edge to deleted node: " &lt;&lt; nodeVal &lt;&lt; std::endl;
  
  
              // delete the edge from the node
              //originNodeOfIncomingEdge-&gt;edges_.erase(edge);
  
  
              auto findLinkingNode1 = nodes_.find(originNodeOfIncomingEdge);
              if (findLinkingNode1 == nodes_.end()) throw std::runtime_error("deleteNode: findLinkingNode1 DNE");
  
          }
  
          findNode-&gt;second.reset(); // deletes managed object of the shared_ptr
          nodes_.erase(findNode); // removes the node from the map container
  
  
      }
  }
  </code></pre>
  
  <p>The following is some of the declarations of my Graph class:</p>
  
  <pre><code>template &lt;typename N, typename E&gt; class Graph {
  
      private:
          struct Node;
          struct Edge;
  
          struct Node {
              N val_;
              int numEdges_;
              int numIncomingEdges_;
              std::set&lt;std::shared_ptr&lt;Edge&gt;&gt; edges_;
              std::set&lt;std::shared_ptr&lt;Edge&gt;&gt; incomingEdges_;
              Node() {}
              Node(const N x) : val_{x} { numEdges_=0; }
              void printNode(N n);
              ~Node();
              void update();
          };
  
          struct Edge {
              std::weak_ptr&lt;Node&gt; orig;
              std::weak_ptr&lt;Node&gt; dest;
              E val_;
              Edge(std::shared_ptr&lt;Node&gt; o, std::shared_ptr&lt;Node&gt; d, E x);
              Edge() {};
              void printEdge();
              ~Edge();
          };
  </code></pre>