title: C++ Iterator access next element for comparison
body: <p>I'm trying to compare two elements in a List by 'peeking' into the next element in the list. Using C++11.</p>
  
  <p>Is this possible? I'm having some trouble.</p>
  
  <pre><code>#include &lt;list&gt;
  #include &lt;iostream&gt;
  
  using namespace std;
  
  int main(int argc, char *argv[])
  {
  
      list&lt;int&gt; intList;
  
      intList.push_back(10);
      intList.push_back(20);
      intList.push_back(30);
      intList.push_back(30);
  
  
      list&lt;int&gt;::iterator it;
  
      for (it = intList.begin(); it != intList.end(); it++)
      {
          if (*it == *it + 1)
              cout &lt;&lt; "Duplicate: " &lt;&lt; *it &lt;&lt; '\n';
      }
  }
  </code></pre>