title: Accessing std::vector elements via pointers vs end()
body: <p>I need to be able to access (read-only, no resizing involved or anything like that) the elements of a an <code>std::vector</code> via pointers. E.g.,</p>
  
  <pre><code>std::vector&lt;int&gt; foo(10);
  int *ptr_begin = &amp;foo[0];
  </code></pre>
  
  <p>So far so good, this is guaranteed to work in the current standard (23.3.6.1):</p>
  
  <blockquote>
    <p>The elements of a vector are stored contiguously, meaning that if v is a vector where T is some type other than bool, then it obeys the identity &amp;v[n] == &amp;v[0] + n for all 0 &lt;= n &lt; v.size().</p>
  </blockquote>
  
  <p>So we can access all elements of the vector using pointers, since they are stored in a contiguous chunk of memory. But what about the one-past-the-last element? I mean, it is legal to perform this operation?</p>
  
  <pre><code>int *ptr_end = ptr_begin + foo.size()
  </code></pre>
  
  <p>(Note, I am not trying to access the past-the-last value, merely to define a pointer to it - an equivalent to <code>foo.end()</code> if you like). The standard mentions only accessing elements via pointer arithmetics, but clearly here we are not accessing any element.</p>
  
  <p>(As a side note, the definition of the existence of a past-the-last something seems tightly connected to the base concept of array (see for instance 5.7/5), but throughout the standard it seems like the concepts of contiguous storage and array are used interchangeably. Am I reading wrong?)</p>