Skip to content

Instantly share code, notes, and snippets.

@kahrl kahrl/reserve.cpp
Created Feb 16, 2016

What would you like to do?
template<typename _Tp, typename _Alloc>
vector<_Tp, _Alloc>::
reserve(size_type __n)
if (__n > this->max_size())
if (this->capacity() < __n)
const size_type __old_size = size();
pointer __tmp = _M_allocate_and_copy(__n,
std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
- this->_M_impl._M_start);
this->_M_impl._M_start = __tmp;
this->_M_impl._M_finish = __tmp + __old_size;
this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.