title: Deleting node in a double linked list is not working
body: <p>This is a  basic function that takes an iterator position and deletes the node in this position but it gives me a runtime error. what am i doing wrong?</p>
  <pre><code>iterate erase(iterate position)
  {
      iterate i;
      Node&lt;T&gt;* temp = head;
      if (head == NULL) {
          cout &lt;&lt; &quot;empty list&quot; &lt;&lt; endl;
      }
      else if (position.pointer == head) {
          head = temp-&gt;next;
          temp-&gt;next-&gt;previous = NULL;
          delete position.pointer;
      }
      else {
          while (temp != NULL) {
              if (temp == position.pointer-&gt;previous) {
                  temp-&gt;next = position.pointer-&gt;next;
                  temp-&gt;next-&gt;previous = temp;
                  i.pointer = temp-&gt;next;
                  delete position.pointer;
                  return i;
              }
          }
      }
  </code></pre>