Beispiel #1
0
void _VECTOR_IMPL<_Tp, _Alloc>::_M_fill_insert(iterator __pos,
                                               size_type __n, const _Tp& __x) {
  if (__n != 0) {
    if (size_type(this->_M_end_of_storage._M_data - this->_M_finish) >= __n) {
      _M_fill_insert_aux(__pos, __n, __x, _Movable());
    } else 
      _M_insert_overflow(__pos, __x, _TrivialCpy(), __n);
  }
}
Beispiel #2
0
__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;
}