title: Why the libc++ std::vector internally keeps three pointers instead of one pointer and two sizes?
body: <p>I'm looking at the implementation of <code>std::vector</code> in libc++ and I noticed that it internally keeps three pointers (one to the begin, one the end, and one to the end of the allocated memory) instead of what I'd instinctively do, i.e., one pointer to the begin and two <code>size</code> and <code>capacity</code> members.</p>
  
  <p>Here is the code from libc++'s <code>&lt;vector&gt;</code> (ignore the compressed pair, I know what it means).</p>
  
  <pre><code>pointer                                    __begin_;
  pointer                                    __end_;
  __compressed_pair&lt;pointer, allocator_type&gt; __end_cap_;
  </code></pre>
  
  <p>I noticed that also other standard libraries do the same (e.g. Visual C++).
  I don't see any particular reason why this solution should be faster than the other one, but I might be wrong.</p>
  
  <p>So is there a particular reason the "three pointers" solution is preferred to the "pointer + sizes" one? </p>