title: std::set iterator automatically const
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/2217878/c-stl-set-update-is-tedious-i-cant-change-an-element-in-place">C++ STL set update is tedious: I can&#39;t change an element in place</a>  </p>
  </blockquote>
  
  
  
  <p>I have extracted the problem and changed names and so for simplicities sake.</p>
  
  <p>Basically I instantiate a class and I stock it in a std::set, later on I'd like to have a reference to the class so that I can check its values and modify them...</p>
  
  <p>The simplified code:</p>
  
  <pre><code>        MyClass tmpClass;
          std::set&lt;MyClass &gt; setMyClass;
          setMyClass.insert(tmpClass);
          std::set&lt;MyClass &gt;::iterator iter;
          iter=setMyClass.begin();
          MyClass &amp;tmpClass2=*iter;
  </code></pre>
  
  <p>and the error:</p>
  
  <pre><code>error C2440: 'initializing' : cannot convert from 'const MyClass' to 'MyClass &amp;'
  </code></pre>
  
  <p>(I removed parts of the error message, "MVB::Run::" to clear it up too.)</p>
  
  <p>if I add a preceding 'const' to the last line of code then everything works well but then I can't change the value...</p>
  
  <p>Is this normal behaviour and I have to, say, remove the data, change values and put it back again?</p>
  
  <p>I have the feeling that this has something to do with the sorting of the set but I won't touch the variables that are used for the sorting.</p>