title: I have 9 Elements in the Map, but the distance between begin() and end() is only 2
body: <p>I have a problem in a code where I don't find any solution.</p>
  
  <pre><code>void Buffer::printAllBoards()
  {
      std::cout &lt;&lt; "Total " &lt;&lt; boards_.size() &lt;&lt; " boards." &lt;&lt; std::endl;
      std::map&lt;PlayBoard, InvVertex*&gt;::iterator itr;
      for (itr = boards_.begin(); itr != boards_.end(); ++itr)
      {
          std::cout &lt;&lt; "the distance is " &lt;&lt; distance(boards_.begin(), boards_.end()) &lt;&lt; std::endl;
          //PlayBoard board = itr-&gt;first;
          //board.printBoard();
      }
  }
  </code></pre>
  
  <p>boards_ is a member variable of Buffer, and it has the type std::map&lt; PlayBoard, InvVertex* >.</p>
  
  <p>The output of the program for this part of the code is:</p>
  
  <pre><code>Total 9 boards.
  the distance is 2
  the distance is 2
  </code></pre>
  
  <p>The first line is obvious, because i add 9 elements to the map. But with the iterator I can only access two of them, because either the begin or the end function don't have the correct value.</p>
  
  <p>Does anyone have a solution for that?</p>
  
  <p>Thanks for your answers.</p>
  
  <p>I have provided the code as a download in tar.gz here:
  <a href="http://www.file-upload.net/download-7931142/invers.tar.gz.html" rel="nofollow">http://www.file-upload.net/download-7931142/invers.tar.gz.html</a></p>