Vector的设计
//vector对象本身存储三个指针
template<typename _Tp, typename _Alloc>
struct _Vector_base
{
...
struct _Vector_impl
: public _Tp_alloc_type
{
pointer _M_start; //vector的起始位置
pointer _M_finish;//vector的最后元素的下一位置
pointer _M_end_of_storage;//vector存储空间的最后位置
...
}
...
}
vector的两倍增长
void push_back(const value_type& __x)
{
if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
{
_Alloc_traits::construct(this->_M_impl, this->_M_impl