title: Passing a reference to an offset position in an STL vector
body: <p>I'm trying to convert some old C functions to C++. My original programme stores a matrix in a single array, and I just pass a pointer to the first element to a function so that I am working on the correct row, e.g.</p>
  
  <pre><code>double f1(int *a){
   return a[0] + a[1];
  }
  
  int main(void){
    int x[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
    for(i = 0; i &lt; 5; i++){
    printf("%d\n", f1(&amp;x[2 * i]));
  }
  </code></pre>
  
  <p>I would like to be able to do something similar using the STL <strong>without</strong> copying. So my programme would look something like this</p>
  
  <pre><code>double f1(vector&lt;int&gt;&amp; a){
   return a[0] + a[1];
  }
  int main(void){
    int x[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
    vector&lt;int&gt; y(x, x + 10);
  
    for(i = 0; i &lt; 5; i++){
       cout &lt;&lt; f1(y) &lt;&lt; endl; // This is clearly wrong
  }
  </code></pre>
  
  <p>How would I do this? I could change my function to receive a reference to a vector::iterator I guess, but is there another way?</p>