title: Using iterators on arrays
body: <p>It is stated in <a href="https://rads.stackoverflow.com/amzn/click/com/0321714113" rel="noreferrer" rel="nofollow noreferrer">C++ Primer</a> that</p>
  
  <blockquote>
    <p>In C++ pointers and arrays are closely intertwined. In particular, as
    we’ll see, <strong>when we use an array, the compiler ordinarily converts the
    array to a pointer</strong>.</p>
  </blockquote>
  
  <p>I wanted to use iterators for printing an array. The program below works fine but when I try to print <code>arr2</code> or <code>arr3</code>, if I'm not mistaken, which is of type <code>int *</code>, I get an error (judging that the &amp; operator means reference below). </p>
  
  <blockquote>
    <p><code>error: no matching function for call to ‘begin(int*&amp;)’</code></p>
  </blockquote>
  
  <pre><code>int main(int argc, char** argv) {
  
      int arr[] = {0,1,2,3,4,5,6,7,8,9};
      auto arr2 = arr;
      auto arr3(arr);   // I think arr2 and arr3 are of same type
  
      for(auto it = std::begin(arr) ; it != std::end(arr) ; ++it)
          std::cout &lt;&lt; *it &lt;&lt; " ";
      std::cout &lt;&lt; std::endl;
  
      return 0;
  }
  </code></pre>
  
  <p>Considering the statement, if an array is converted into a pointer by the compiler, how does this program work for printing contents of <code>arr</code> using <code>std::begin()</code> and <code>std::end()</code>  and do not work for <code>arr2</code> or <code>arr3</code> if all of them are pointers to integers?</p>
  
  <hr>
  
  <p><strong>Edit</strong></p>
  
  <p>I'm sorry if I couldn't make it clear. I hope I'll clarify the problem by this edit. </p>
  
  <p>Now that I am aware that <code>begin()</code> and <code>end()</code> won't work with pointers (thanks to the answers), I wonder if the quoted text is not true as it specifies that there is an <strong>Array -> Pointer</strong> conversion. If what text says is true then the type of <code>arr</code> should be a pointer. Is there a problem with the quoted text at this point?</p>
  
  <p>Also, is there any way that I can use <code>begin()</code> and <code>end()</code> for pointers (not STL containers) with specifying the size, possibly using the following constructor?</p>
  
  <pre><code>template&lt; class T, size_t N &gt; 
  T* begin( T (&amp;array)[N] );
  </code></pre>