title: remove_if on a map trying to pass a const as a non-const - why?
body: <p>Here's a bit of code which is supposed to filter out the elements of a map which satisfy a predicate, into a new map (MCVE-fied):</p>
  
  <pre><code>#include &lt;algorithm&gt;
  #include &lt;unordered_map&gt;
  #include &lt;iostream&gt;
  
  using namespace std;
  
  int main() {
      unordered_map&lt;string, int&gt; m = { { "hello", 1 }, { "world", 2 } };
      auto p = [](const decltype(m)::value_type&amp; e) { return e.second == 2; };
      const auto&amp; m2(m);
      auto m3(m2);
      auto it = remove_if(m3.begin(), m3.end(), p);
      m3.erase(it, m3.end());
      cout &lt;&lt; "m3.size() = " &lt;&lt; m3.size() &lt;&lt; endl;
      return 0;
  }
  </code></pre>
  
  <p>Compilation fails on the remove_if() line, and I get:</p>
  
  <pre><code>In file included from /usr/include/c++/4.9/utility:70:0,
                   from /usr/include/c++/4.9/algorithm:60,
                   from /tmp/b.cpp:1:
  /usr/include/c++/4.9/bits/stl_pair.h: In instantiation of ‘std::pair&lt;_T1, _T2&gt;&amp; std::pair&lt;_T1, _T2&gt;::operator=(std::pair&lt;_T1, _T2&gt;&amp;&amp;) [with _T1 = const std::basic_string&lt;char&gt;; _T2 = int]’:
  /usr/include/c++/4.9/bits/stl_algo.h:868:23:   required from ‘_ForwardIterator std::__remove_if(_ForwardIterator, _ForwardIterator, _Predicate) [with _ForwardIterator = std::__detail::_Node_iterator&lt;std::pair&lt;const std::basic_string&lt;char&gt;, int&gt;, false, true&gt;; _Predicate = __gnu_cxx::__ops::_Iter_pred&lt;main()::&lt;lambda(const value_type&amp;)&gt; &gt;]’
  /usr/include/c++/4.9/bits/stl_algo.h:937:47:   required from ‘_FIter std::remove_if(_FIter, _FIter, _Predicate) [with _FIter = std::__detail::_Node_iterator&lt;std::pair&lt;const std::basic_string&lt;char&gt;, int&gt;, false, true&gt;; _Predicate = main()::&lt;lambda(const value_type&amp;)&gt;]’
  /tmp/b.cpp:12:48:   required from here
  /usr/include/c++/4.9/bits/stl_pair.h:170:8: error: passing ‘const std::basic_string&lt;char&gt;’ as ‘this’ argument of ‘std::basic_string&lt;_CharT, _Traits, _Alloc&gt;&amp; std::basic_string&lt;_CharT, _Traits, _Alloc&gt;::operator=(const std::basic_string&lt;_CharT, _Traits, _Alloc&gt;&amp;) [with _CharT = char; _Traits = std::char_traits&lt;char&gt;; _Alloc = std::allocator&lt;char&gt;]’ discards qualifiers [-fpermissive]
    first = std::forward&lt;first_type&gt;(__p.first);
          ^
  </code></pre>
  
  <p>Why is this happening? <code>remove_if</code> should not need non-const map keys (strings in this case) - if I am not mistaken. Perhaps the <code>auto</code>s assume somehow I want non-const iterators? If so, what do I do other tha spelling out the type (I want to avoid that since this code needs to be templated).</p>