title: Why does sizeof(std::vector<int>) return 16 bytes, when it appears there are 20 bytes worth of member data?
body: <p>As some opening info, I'm working with Visual Studio 2013 Community. I've noticed a mismatch between what appears to be inside a <code>std::vector</code>, and what is returned from sizeof, and I was wondering if anyone could shed any light on why this is how it is.</p>
  
  <p>If I declare an empty vector: </p>
  
  <pre><code>std::vector&lt;int&gt; v;
  </code></pre>
  
  <p>then <code>sizeof(v)</code> is 16 bytes.</p>
  
  <p>4 for the ptr to the first element. _MyFirst</p>
  
  <p>4 for the ptr to just after the last element. _MyLast</p>
  
  <p>4 for the capacity int.</p>
  
  <p>4 for the size int.</p>
  
  <p>Which makes sense.. except there is another member ptr in the vector class, to the end of the vector's capacity called _MyEnd.</p>
  
  <p>So why does <code>sizeof(v)</code> not return 20 bytes?!</p>
  
  <p><strong>EDIT:</strong> Turns out some of my assertions were wrong :) The answers below pointed me in the right direction... just in case anyone comes across this in future and is puzzled.</p>
  
  <p>The size of 16 was in debug mode, in release <code>sizeof</code> returns 12.
  The 12 is the 3 pointers, <code>_MyFirst</code>, <code>_MyLast</code> and <code>_MyEnd</code>.</p>