void _VectorBase::_M_reserve_and_clear(size_t __count) { STL_ASSERT((_M_get_finish() >= _M_get_start()) && (_M_get_end_of_storage() >= _M_get_finish())); if (static_cast<size_t>(_M_get_end_of_storage() - _M_get_start()) >= __count) { return; } _M_clear(); __M_start = __M_finish = STL_Malloc(__count); __M_end_of_storage = _M_get_start() + __count; }
void _VectorBase::_M_insert_overflow(void* __pos, size_t __count, const void* __data, size_t __unit_size) { STL_ASSERT((static_cast<char*>(__pos) >= _M_get_start()) && (static_cast<char*>(__pos) <= _M_get_finish()) && (__data != NULL)); size_t __new_size = _M_compute_next_size(__count, __unit_size); STL_ASSERT(__new_size > 0); void* __new_start = STL_Malloc(__new_size); void* __new_finish = _copy_trivial(_M_get_start(), __pos, __new_start); __new_finish = _fill_n_trivial(__new_finish, __count, __data, __unit_size); __new_finish = _copy_trivial(__pos, _M_get_finish(), __new_finish); _M_clear(); _M_set(__new_start, __new_finish, static_cast<char*>(__new_start) + __new_size); }
void _VectorBase::_M_reserve(size_t __count) { STL_ASSERT((_M_get_finish() >= _M_get_start()) && (_M_get_end_of_storage() >= _M_get_finish())); if (static_cast<size_t>(_M_get_end_of_storage() - _M_get_start()) >= __count) { return; } void* __new_start = STL_Malloc(__count); __M_finish = _copy_trivial(_M_get_start(), _M_get_finish(), __new_start); _M_clear(); _M_set(__new_start, __M_finish, static_cast<char*>(__new_start) + __count); }
void _VECTOR_IMPL<_Tp, _Alloc>::_M_insert_overflow(pointer __pos, const _Tp& __x, const __true_type& /*_TrivialCpy*/, size_type __fill_len, bool __atend ) { const size_type __old_size = size(); const size_type __len = __old_size + (max)(__old_size, __fill_len); pointer __new_start = this->_M_end_of_storage.allocate(__len); pointer __new_finish = (pointer)__copy_trivial(this->_M_start, __pos, __new_start); // handle insertion __new_finish = __fill_n(__new_finish, __fill_len, __x); if (!__atend) __new_finish = (pointer)__copy_trivial(__pos, this->_M_finish, __new_finish); // copy remainder _M_clear(); _M_set(__new_start, __new_finish, __new_start + __len); }
void __vector__<_Tp, _Alloc>::reserve(size_type __n) { if (capacity() < __n) { const size_type __old_size = size(); pointer __tmp; if (this->_M_start) { __tmp = _M_allocate_and_copy(__n, this->_M_start, this->_M_finish); _M_clear(); } else { __tmp = this->_M_end_of_storage.allocate(__n); } _M_set(__tmp, __tmp + __old_size, __tmp + __n); } }
void _VECTOR_IMPL<_Tp, _Alloc>::reserve(size_type __n) { if (capacity() < __n) { if (max_size() < __n) { this->_M_throw_length_error(); } const size_type __old_size = size(); pointer __tmp; if (this->_M_start) { __tmp = _M_allocate_and_copy(__n, this->_M_start, this->_M_finish); _M_clear(); } else { __tmp = this->_M_end_of_storage.allocate(__n); } _M_set(__tmp, __tmp + __old_size, __tmp + __n); } }
_VECTOR_IMPL<_Tp,_Alloc>& _VECTOR_IMPL<_Tp,_Alloc>::operator=(const _VECTOR_IMPL<_Tp, _Alloc>& __x) { if (&__x != this) { const size_type __xlen = __x.size(); if (__xlen > capacity()) { pointer __tmp = _M_allocate_and_copy(__xlen, __CONST_CAST(const_pointer, __x._M_start)+0, __CONST_CAST(const_pointer, __x._M_finish)+0); _M_clear(); this->_M_start = __tmp; this->_M_end_of_storage._M_data = this->_M_start + __xlen; } else if (size() >= __xlen) { pointer __i = __copy_ptrs(__CONST_CAST(const_pointer, __x._M_start)+0, __CONST_CAST(const_pointer, __x._M_finish)+0, this->_M_start, _TrivialAss()); _STLP_STD::_Destroy_Range(__i, this->_M_finish); } else { __copy_ptrs(__CONST_CAST(const_pointer, __x._M_start), __CONST_CAST(const_pointer, __x._M_start) + size(), this->_M_start, _TrivialAss()); __uninitialized_copy(__CONST_CAST(const_pointer, __x._M_start) + size(), __CONST_CAST(const_pointer, __x._M_finish)+0, this->_M_finish, _TrivialUCpy()); } this->_M_finish = this->_M_start + __xlen; } return *this; }
__vector__<_Tp,_Alloc>& __vector__<_Tp,_Alloc>::operator=(const __vector__<_Tp, _Alloc>& __x) { if (&__x != this) { const size_type __xlen = __x.size(); if (__xlen > capacity()) { pointer __tmp = _M_allocate_and_copy(__xlen, (const_pointer)__x._M_start+0, (const_pointer)__x._M_finish+0); _M_clear(); this->_M_start = __tmp; this->_M_end_of_storage._M_data = this->_M_start + __xlen; } else if (size() >= __xlen) { pointer __i = __copy_ptrs((const_pointer)__x._M_start+0, (const_pointer)__x._M_finish+0, (pointer)this->_M_start, _TrivialAss()); _STLP_STD::_Destroy(__i, this->_M_finish); } else { __copy_ptrs((const_pointer)__x._M_start, (const_pointer)__x._M_start + size(), (pointer)this->_M_start, _TrivialAss()); __uninitialized_copy((const_pointer)__x._M_start + size(), (const_pointer)__x._M_finish+0, this->_M_finish, _IsPODType()); } this->_M_finish = this->_M_start + __xlen; } return *this; }