title: How to get the first element of a std::set
body: <p>I you all,</p>
  
  <p>I found a strange bug in my software.</p>
  
  <p>Inside a while loop where I remove elements from a std::set, I want always to take the first element until the container is empty:</p>
  
  <pre><code>std::set&lt; int*&gt; nodes;
  // Fill nodes 
  for (int i=0; i&lt;10;i++)
     nodes.insert(new int);
  //
  while (!nodes.empty())
  {
  int* pivot  = (*nodes.begin());
  // do some operation with pivot erasing some elements from nodes
  }
  </code></pre>
  
  <p>I found that implementing the first element this way works with gcc but not with MSVC, it crashes where I try to dereference the <code>(*nodes.begin())</code> iterator.</p>
  
  <p>Do the two implementation of std::set behave differently?</p>
  
  <p>I would like to have a data structure with no differences of implementation, is it possible?</p>
  
  <p>Probably I must change data structure for this kind of operations </p>