title: What is the exact type of auto variable with multi-dim array in for-range in C++
body: <p>For comparison, let me state my understanding first. For one-dimensional array, <code>int arr[3]={1,2,3}</code>, we know that</p>
  <ol>
  <li><code>arr</code> is an array, which can decay to a pointer if wanted</li>
  <li><code>arr[0]</code> is the first element of the array</li>
  <li><code>&amp;arr</code> is a pointer to 'entire' array, which has different behavior than <code>arr</code> under pointer arithmetic (c.f. <code>arr+1</code> and <code>(&amp;arr)+1</code>).</li>
  </ol>
  <p>Now, I wonder what exactly is the type of the <code>mat[0]</code> in:</p>
  <pre class="lang-c prettyprint-override"><code>    int mat[2][3] = { {10, 20, 30}, {40, 50, 60} };
  </code></pre>
  <p>Is <code>mat[0]</code> something as 1, 2 or 3? I guess it was something as 1. But it proved that I was wrong because I found that:</p>
  <pre class="lang-c prettyprint-override"><code>cout &lt;&lt; *((&amp;mat[0]) + 1); // not 40, but random address, say 000000AEE4EFF604
  </code></pre>
  <p>where I expected that <code>(&amp;mat[0]) + 1</code> would point to the memory address of <code>40</code>. So is it case 3? But how?</p>
  <p>Moreover, another harder problem is what type the iterator <code>it</code> in for-range exactly is. Again, does it belong to 1, 2, or 3?</p>
  <pre class="lang-c prettyprint-override"><code>    for (auto it : mat) {
          ...
      }
  </code></pre>