title: Range-based for loop on unordered_map and references
body: <p>When running a range-based for loop on an std::unordered_map it appears that the type of the loop variable does not use reference types:</p>
  
  <pre><code>std::unordered_map&lt;int, int&gt; map = { {0, 1}, {1, 2}, {2, 3} };
  for(auto&amp;[l, r] : map)
      static_assert(std::is_same_v&lt;decltype(r), int&amp;&gt;);
  </code></pre>
  
  <p>MSVC 2017, gcc 8.2 and clang 7.0.0 all report a failed assertion here. Oppose this to a std::vector, where the assertion does not fail, as one would expect:</p>
  
  <pre><code>std::vector&lt;int&gt; vec = { 1, 2, 3 };
  for(auto&amp; r : vec)
      static_assert(std::is_same_v&lt;decltype(r), int&amp;&gt;);
  </code></pre>
  
  <p>However on both MSVC 2017 and gcc 8.2 a loop modifying the local variable <em>r</em> will have observable side-effects:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;type_traits&gt;
  #include &lt;unordered_map&gt;
  #include &lt;vector&gt;
  
  int main() {
      std::unordered_map&lt;int, int&gt; a = { {0, 1}, {1, 2}, {2, 3} };
      for(auto[l, r] : a)
          std::cout &lt;&lt; l &lt;&lt; "; " &lt;&lt; r &lt;&lt; std::endl;
      for(auto&amp;[l, r] : a) {
          static_assert(std::is_same_v&lt;decltype(r), int&gt;);
          r++;
      }
      std::cout &lt;&lt; "Increment:" &lt;&lt; std::endl;
      for(auto[l, r] : a)
          std::cout &lt;&lt; l &lt;&lt; "; " &lt;&lt; r &lt;&lt; std::endl;
  }
  </code></pre>
  
  <p>This program for example will print (ignoring order):</p>
  
  <pre><code>0; 1
  1; 2
  2; 3
  Increment:
  0; 2
  1; 3
  2; 4
  </code></pre>
  
  <p>What am I missing?
  How can this change the value in the map despite the local variable not being of reference type?
  Or probably more appropriately, why does <em>std::is_same</em> not see the right type, because quite clearly it is a reference type?
  Or am I alternatively missing some undefined behavior?</p>
  
  <p>Note that I did reproduce the same issue without using structured bindings, so I keep the nice looking code here.
  <a href="https://godbolt.org/z/WS-ZgE" rel="noreferrer">See here for an example</a></p>