title: Assigning a const_iterator to an iterator
body: <p>I have the below snippet of code (which you can run here: <a href="http://coliru.stacked-crooked.com/a/2f62134b5c125051" rel="nofollow noreferrer">http://coliru.stacked-crooked.com/a/2f62134b5c125051</a>)</p>
  <pre><code>#include &lt;iostream&gt;
  #include &lt;set&gt;
  #include &lt;map&gt;
  
  int main() 
  {
      std::set&lt;std::pair&lt;const int, const int&gt;&gt; const mySet{{0,0}}; // value_type = std::pair&lt;const int, const int&gt;
      for (std::set&lt;std::pair&lt;const int, const int&gt;&gt;::iterator it  = mySet.cbegin(); it != mySet.cend(); ++it)
      {
          std::cout&lt;&lt;&quot;set it = &quot; &lt;&lt; it-&gt;first &lt;&lt; &quot; &quot; &lt;&lt; it-&gt;second &lt;&lt; std::endl;
      }
  
      std::map&lt;const int, const int&gt; const myMap{{0,0}}; // value_type = std::pair&lt;const int, const int&gt;
      for (std::map&lt;const int, const int&gt;::iterator it  = myMap.cbegin(); it != myMap.cend(); ++it)
      {
          std::cout&lt;&lt;&quot;map it = &quot; &lt;&lt; it-&gt;first &lt;&lt; &quot; &quot; &lt;&lt; it-&gt;second &lt;&lt; std::endl;
      }   
  }
  </code></pre>
  <p>Can someone please explain me why for <em>std::set</em> the below does not throw any error:</p>
  <pre><code>std::set&lt;std::pair&lt;const int, const int&gt;&gt;::iterator it  = mySet.cbegin();
  </code></pre>
  <p>while for <em>std::map</em> the below throws error (no known conversion from <em>_Rb_tree_const_iterator&lt;std::pair&lt;const int, const int&gt; &gt;</em> to <em>_Rb_tree_iterator&lt;std::pair&lt;const int, const int&gt; &gt;</em>) as expected:</p>
  <pre><code>std::map&lt;const int, const int&gt;::iterator it  = myMap.cbegin();
  </code></pre>
  <p>How does it work for <em>std::set</em>? Shouldn't assigning a <em>const_iterator</em> to an <em>iterator</em> always throw an error?</p>