title: Iteration over set elements in C++ does not compile
body: <p>I haven't worked with C++ for several years and now I'm required to maintain a C++ project. I have the following piece of code which seems to compile in one project, but not in the other. </p>
  
  <p>list.h</p>
  
  <pre><code>#include "mytype.h"
  #include &lt;set&gt;
  
  typedef std::set&lt;MYTYPE&gt; MYTYPE_LIST;
  typedef MYTYPE_LIST::iterator MYTYPE_LIST_ITERATOR;
  
  class LIST {
  
  [...]
  
  MYTYPE_LIST list;
  };
  </code></pre>
  
  <p>list.cpp</p>
  
  <pre><code>void 
  LIST::somemethod(MYTYPE* requester)
  {
  
     MYTYPE_LIST_ITERATOR it;
     for (it = list.begin(); it != list.end() ; it++ )
     {
        MYTYPE&amp; info = (*it); // Error on this line
        [...]
     }
  }
  </code></pre>
  
  <p>I am compiling my project with VS 2010, and I get the following errors on the marked line:</p>
  
  <pre><code>error C2440: 'initializing' : cannot convert from 'const MYTYPE' to 'MYTYPE &amp;'
  IntelliSense: qualifiers dropped in binding reference of type "MYTYPE &amp;" to initializer of type "const MYTYPE"
  </code></pre>
  
  <p>I googled these errors, and as far as I understand, (*it) should not be const (because 'it' is not a ::const_iterator, see <a href="https://stackoverflow.com/questions/309581/const-and-nonconst-stl-iterators">here</a>), and therefor, I should be able to assign it to the reference variable.</p>