"Forced constness" in std::map<std::vector<int>,double> >?
<p>Consider this program:</p>

<pre><code>#include &lt;map&gt;
#include &lt;vector&gt;
typedef std::vector&lt;int&gt; IntVector;
typedef std::map&lt;IntVector,double&gt; Map;
void foo(Map&amp; m,const IntVector&amp; v)
{
   Map::iterator i = m.find(v);
   i-&gt;first.push_back(10);
};
int main()
{
   Map m;
   IntVector v(10,10);
   foo(m,v);
   return 0;
}
</code></pre>

<p>Using g++ 4.4.0, I get his compilation error:</p>

<pre><code>test.cpp: In function 'void foo(Map&amp;, const IntVector&amp;)':
test.cpp:8: error: passing 'const std::vector&lt;int, std::allocator&lt;int&gt; &gt;' as 'this' argument of 'void std::vector&lt;_Tp, _Alloc&gt;::push_back(const _Tp&amp;) [with _Tp = int, _Alloc = std::allocator&lt;int&gt;]' discards qualifiers
</code></pre>

<p>I would expect this error if I was using <code>Map::const_iterator</code> inside foo but not using a non-const iterator.</p>

<p>What am I missing, why do I get this error?</p>
