figure removing node specified by from doubly linked list /erase item at itr iterator eraseiterator itr node * itr currentiterator retvalp->next } ->prev->next ->nextp->next->prev ->prevdelete pthesize--return retvaliterator eraseiterator fromiterator to foriterator itr fromitr !toitr eraseitr )return tofigure erase routines for list class the erased element like inserterase must update thesize the second version of erase simply uses an iterator to call the first version of erase note that we cannot simply use itr+in the for loop at line and ignore the return value of erase at line the value of itr is stale immediately after the call to erasewhich is why erase returns an iterator in examining the codewe can see host of errors that can occur and for which no checks are provided for instanceiterators passed to erase and insert can be uninitialized or for the wrong listiterators can have +or applied to them when they are already at the endmarker or are uninitialized an uninitialized iterator will have current pointing at nullptrso that condition is easily tested the endmarker' next pointer points at nullptrso testing for +or on an endmarker condition is also easy howeverin order to determine if an iterator passed to erase or insert is an iterator for the correct listthe iterator must store an additional data member representing pointer to the list from which it was constructed