title: Implementing begin() and end() for doubly linked list
body: <p>I have written my own container class whose original internal data structure was the <code>std::list</code>. I then needed to create my own doubly linked list. I have now implemented my own doubly linked list as well as my own iterator for the linked list, but I'm having problems getting it to behave like <code>std::list</code>, particularly with <code>begin()</code> and <code>end()</code>.</p>
  
  <p>From what I understand, <code>begin()</code> should point the first node, and <code>end()</code> should point one element past the last element. I need to make sure that when I call <code>end()</code> that I can decrement back to the valid last element. I also need to make sure that I can do your normal traversals like...</p>
  
  <pre><code>while (beg != end ) { do something; beg++; }
  </code></pre>
  
  <p>Essentially my linked list just uses nodes that contain a data element, a pointer to the previous node and a pointer to the next node.</p>
  
  <p>When I first tried to implement my <code>end()</code>, I just had the last node's next pointer be a <code>nullptr</code>. It works on its own but does not act the same way as the stl.</p>
  
  <p>Any advice on how to implement the <code>begin()</code> and <code>end()</code> the same way the standard library does?</p>