title: How to efficiently compare two maps of strings in C++ only for a subset of the keys
body: <p>I'm wondering if only by applying some standard algorithms is possible to write a short function which compares two <code>std::map&lt;string, string&gt;</code> and returns true if all the key-value (but some) pairs are true.</p>
  <p>For example, these two maps should be evaluated as <em>equal</em></p>
  <pre><code>map&lt;string,string&gt; m1, m2;
  
  m1[&quot;A&quot;]=&quot;1&quot;;
  m2[&quot;A&quot;]=&quot;1&quot;;
  
  m1[&quot;B&quot;]=&quot;2&quot;;
  m2[&quot;B&quot;]=&quot;2&quot;;
  
  m1[&quot;X&quot;]=&quot;30&quot;;
  m2[&quot;X&quot;]=&quot;340&quot;;
  
  m1[&quot;Y&quot;]=&quot;53&quot;;
  m2[&quot;Y&quot;]=&quot;0&quot;;
  </code></pre>
  <p>Suppose that the two maps have same size and all their elements must be pairwise compared except the value stored by the key &quot;X&quot; and key &quot;Y&quot;. A first attempt would be a very inefficient double nested for loop.</p>
  <p>I'm sure a better solution can be achieved.</p>