title: Implementing custom iterators in C++11
body: <p>I am reading a book, and I started the <strong>Templates</strong> chapter. I have already read the chapter about iterators. For practicing, I am trying to implement a doubly-linked class using templates. Below is the header file of my class. </p>
  
  <pre><code>template&lt;typename T&gt;
  class list
  {
  private:
      T* first_node;
      T* last_node;
      struct node_structure
      {
          T* previous;
          T* next;
          T content;
      };
  public:
      list();
      void push_back( T&amp; item );
      void push_front( T&amp; item );
      void remove( size_t index );
      size_t size() const;
      T&amp; get_node( size_t index );
      void clear();
      ~list();
  };
  </code></pre>
  
  <p>I could have set two members:</p>
  
  <pre><code>T* begin();
  T* end();
  </code></pre>
  
  <p>...to act like very basic iterators, but they are not iterators actually. So, I have a question:</p>
  
  <p>How do I implement the custom iterator class to be used with all the arithmetic operations and to have <code>begin()</code>, <code>cbegin()</code>, <code>end()</code>, and <code>cend()</code>?</p>
  
  <p><sub>(I am aware that creating a list class will not be as efficient as <code>std::list</code>, but I am doing this just for sake of practicing.)</sub></p>