Ejemplo n.º 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);
  }
}
Ejemplo n.º 2
0
void _VECTOR_IMPL<_Tp, _Alloc>::_M_fill_insert_aux (iterator __pos, size_type __n, 
                                                    const _Tp& __x, const __true_type& /*_Movable*/) {
  if (&__x >= this->_M_start && &__x < this->_M_finish) {
    _Tp __x_copy = __x;
    _M_fill_insert_aux(__pos, __n, __x_copy, __true_type());
    return;
  }
  iterator __src = this->_M_finish;
  iterator __dst = __src + __n;
  for (; __src != __pos; --__dst, --__src) {
    _STLP_STD::_Move_Construct(__dst, *__src);
    _STLP_STD::_Destroy_Moved(__src);
  }
  _STLP_STD::fill(__pos, __dst, __x);
}
Ejemplo n.º 3
0
void _VECTOR_IMPL<_Tp, _Alloc>::_M_fill_insert_aux (iterator __pos, size_type __n, 
                                                    const _Tp& __x, const __true_type& /*_Movable*/) {
  if (_M_is_inside(__x)) {
    _Tp __x_copy = __x;
    _M_fill_insert_aux(__pos, __n, __x_copy, __true_type());
    return;
  }
  iterator __src = this->_M_finish - 1;
  iterator __dst = __src + __n;
  for (; __src >= __pos; --__dst, --__src) {
    _STLP_STD::_Move_Construct(__dst, *__src);
    _STLP_STD::_Destroy_Moved(__src);
  }
  __uninitialized_fill_n(__pos, __n, __x, _PODType());
  this->_M_finish += __n;
}
Ejemplo n.º 4
0
void _VectorBase::_M_fill_insert(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()) 
               && (_M_get_end_of_storage() >= _M_get_finish()) && (__data != NULL));
    if (__count <= 0)
    {
        return;
    }

    if (static_cast<size_t>(_M_get_end_of_storage() - _M_get_finish()) >= (__count * __unit_size))
    {
        _M_fill_insert_aux(__pos, __count, __data, __unit_size);
    }
    else
    {
        _M_insert_overflow(__pos, __count, __data, __unit_size);
    }
}
Ejemplo n.º 5
0
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);
  }
}
Ejemplo n.º 6
0
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);
  }
}