void __vector__<_Tp, _Alloc>::_M_fill_insert( iterator __position, size_type __n, const _Tp& __x) { if (__n != 0) { if (size_type(this->_M_end_of_storage._M_data - this->_M_finish) >= __n) { _Tp __x_copy = __x; const size_type __elems_after = this->_M_finish - __position; pointer __old_finish = this->_M_finish; if (__elems_after > __n) { __uninitialized_copy(this->_M_finish - __n, this->_M_finish, this->_M_finish, _IsPODType()); this->_M_finish += __n; __copy_backward_ptrs(__position, __old_finish - __n, __old_finish, _TrivialAss()); _STLP_STD::fill(__position, __position + __n, __x_copy); } else { uninitialized_fill_n(this->_M_finish, __n - __elems_after, __x_copy); this->_M_finish += __n - __elems_after; __uninitialized_copy(__position, __old_finish, this->_M_finish, _IsPODType()); this->_M_finish += __elems_after; _STLP_STD::fill(__position, __old_finish, __x_copy); } } else _M_insert_overflow(__position, __x, _IsPODType(), __n); } }
void _VECTOR_IMPL<_Tp, _Alloc>::_M_fill_insert_aux (iterator __pos, size_type __n, const _Tp& __x, const __false_type& /*_Movable*/) { //Here self referencing needs to be checked even for non movable types. if (_M_is_inside(__x)) { _Tp __x_copy = __x; _M_fill_insert_aux(__pos, __n, __x_copy, __false_type()); return; } const size_type __elems_after = this->_M_finish - __pos; pointer __old_finish = this->_M_finish; if (__elems_after > __n) { __uninitialized_copy(this->_M_finish - __n, this->_M_finish, this->_M_finish, _TrivialUCpy()); this->_M_finish += __n; __copy_backward_ptrs(__pos, __old_finish - __n, __old_finish, _TrivialAss()); _STLP_STD::fill(__pos, __pos + __n, __x); } else { this->_M_finish = __uninitialized_fill_n(this->_M_finish, __n - __elems_after, __x, _PODType()); __uninitialized_copy(__pos, __old_finish, this->_M_finish, _TrivialUCpy()); this->_M_finish += __elems_after; _STLP_STD::fill(__pos, __old_finish, __x); } }
void _VECTOR_IMPL<_Tp, _Alloc>::_M_fill_insert_aux (iterator __pos, size_type __n, const _Tp& __x, const __false_type& /*_Movable*/) { if (&__x >= this->_M_start && &__x < this->_M_finish) { _Tp __x_copy = __x; _M_fill_insert_aux(__pos, __n, __x_copy, __false_type()); return; } const size_type __elems_after = this->_M_finish - __pos; pointer __old_finish = this->_M_finish; if (__elems_after > __n) { __uninitialized_copy(this->_M_finish - __n, this->_M_finish, this->_M_finish, _TrivialUCpy()); this->_M_finish += __n; __copy_backward_ptrs(__pos, __old_finish - __n, __old_finish, _TrivialAss()); _STLP_STD::fill(__pos, __pos + __n, __x); } else { uninitialized_fill_n(this->_M_finish, __n - __elems_after, __x); this->_M_finish += __n - __elems_after; __uninitialized_copy(__pos, __old_finish, this->_M_finish, _TrivialUCpy()); this->_M_finish += __elems_after; _STLP_STD::fill(__pos, __old_finish, __x); } }
__iterator__ _VECTOR_IMPL<_Tp, _Alloc>::insert(iterator __pos, const _Tp& __x) { size_type __n = __pos - begin(); if (this->_M_finish != this->_M_end_of_storage._M_data) { if (__pos == end()) { _Copy_Construct(this->_M_finish, __x); ++this->_M_finish; } else { if (&__x >= this->_M_start && &__x < this->_M_finish) { _Tp __x_copy = __x; insert(__pos, __x_copy); } else { _Copy_Construct(this->_M_finish, *(this->_M_finish - 1)); ++this->_M_finish; __copy_backward_ptrs(__pos, this->_M_finish - 2, this->_M_finish - 1, _TrivialAss()); *__pos = __x; } } } else _M_insert_overflow(__pos, __x, _TrivialCpy(), 1UL); return begin() + __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; }