title: Using Structured binding declaration in Range-based for loop
body: <p>I am trying to combine two <code>std::map</code> containers (say <code>std::map&lt;int, int&gt; foo, bar</code>) into a third <code>std::map</code> (say <code>std::map&lt;int, int&gt; foobar</code>).</p>
  <p>I know that I can achieve this using iterators as below:</p>
  <pre><code>    std::map&lt;int, int&gt;::iterator itr1 = foo.begin();
      std::map&lt;int, int&gt;::iterator itr2 = bar.begin();
  
      for (; itr1 != foo.end() &amp;&amp; itr2 != bar.end(); ++itr1, ++itr2) 
      {
        foobar[itr1-&gt;first] += itr1-&gt;second;
        foobar[itr2-&gt;first] += itr2-&gt;second;
      }
  </code></pre>
  <p>But how can I use Range-based for loop (and maybe, in conjunction with Structured binding declaration) to achieve the same?</p>
  <p>Or is there any better way to combine these two associative containers?</p>
  <p>EDIT: The expected answer to this question should take two containers (<code>std::map</code> here) and combine them into a single union/united map with the keys being from both the respective associative containers and the values of duplicate keys being added.</p>
  <p><strong>Example:</strong>
  If given <code>std::map</code> containers <code>foo</code> and <code>bar</code> are:</p>
  <pre><code>  std::map&lt;int, int&gt; foo = {{1, 10}, {2, 20}, {3, 30}};
    std::map&lt;int, int&gt; bar = {{3, 50}, {4, 60}};
  </code></pre>
  <p>Then `foobar' should be:</p>
  <pre><code>  std::map&lt;int, int&gt; foobar = {{1, 10}, {2, 20}, {3, 80}, {4, 60}};
  </code></pre>
  <p>This all done in a <em><strong>single Range-based for loop</strong></em>.</p>