title: C++ priority_queue using map with lambda comparator error
body: <p>I'm trying to implement my own key comparator for std::proirity_queue as follows:</p>
  
  <pre><code>funtion insertInPQ(vector&lt;int&gt; nums){
     map&lt;int,int&gt; m;
     for(int i=0;i&lt;nums.size();i++)
       m[nums[i]]++;
  
     auto comp = []( int a, int b ) 
     { 
          return m[a] &lt; m[b]; 
     };
     priority_queue&lt;int, vector&lt;int&gt;, decltype(comp)&gt; pq(comp);
     for(auto it=m.begin();it!=m.end();it++)
          pq.push(it-&gt;first);
  }
  </code></pre>
  
  <p>But its giving error:</p>
  
  <p><strong>In lambda function:
  Line 10: Char 23: error: passing 'const std::map' as 'this' argument discards qualifiers [-fpermissive]
               return m[a] &lt; m[b];</strong></p>