This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template<typename _Tp, typename _Alloc> | |
void | |
vector<_Tp, _Alloc>:: | |
reserve(size_type __n) | |
{ | |
if (__n > this->max_size()) | |
__throw_length_error(__N("vector::reserve")); | |
if (this->capacity() < __n) | |
{ | |
const size_type __old_size = size(); | |
pointer __tmp = _M_allocate_and_copy(__n, | |
_GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(this->_M_impl._M_start), | |
_GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(this->_M_impl._M_finish)); | |
std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish, | |
_M_get_Tp_allocator()); | |
_M_deallocate(this->_M_impl._M_start, | |
this->_M_impl._M_end_of_storage | |
- 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