title: Are std::vector elements guaranteed to be contiguous?
body: <p>My question is simple: are <code>std::vector</code> elements guaranteed to be contiguous?  In other words, can I use the pointer to the first element of a <code>std::vector</code> as a C-array?</p>
  <p>If my memory serves me well, the C++ standard did not make such guarantee.  However, the <code>std::vector</code> requirements were such that it was virtually impossible to meet them if the elements were not contiguous.</p>
  <p>Can somebody clarify this?</p>
  <p>Example:</p>
  <pre><code>std::vector&lt;int&gt; values;
  // ... fill up values
  
  if( !values.empty() )
  {
      int *array = &amp;values[0];
      for( int i = 0; i &lt; values.size(); ++i )
      {
          int v = array[i];
          // do something with 'v'
      }
  }
  </code></pre>