コード例 #1
0
ファイル: _vector.c プロジェクト: RenEvo/dead6
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);
  }
}
コード例 #2
0
ファイル: _vector.c プロジェクト: hackshields/antivirus
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);
  }
}
コード例 #3
0
ファイル: _vector.c プロジェクト: RenEvo/dead6
void _VECTOR_IMPL<_Tp, _Alloc>::_M_insert_overflow_aux(pointer __pos, const _Tp& __x, const __false_type& /*NOT TO USE!!*/,
                                                       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 = __new_start;
  _STLP_TRY {
    __new_finish = __uninitialized_move(this->_M_start, __pos, __new_start, _TrivialUCpy(), _Movable());
    // handle insertion
    if (__fill_len == 1) {
      _Copy_Construct(__new_finish, __x);
      ++__new_finish;
    } else
      __new_finish = __uninitialized_fill_n(__new_finish, __fill_len, __x, __false_type());
    if (!__atend)
      __new_finish = __uninitialized_move(__pos, this->_M_finish, __new_finish, _TrivialUCpy(), _Movable()); // copy remainder
  }
  _STLP_UNWIND((_STLP_STD::_Destroy_Range(__new_start,__new_finish),
               this->_M_end_of_storage.deallocate(__new_start,__len)))
  _M_clear_after_move();
  _M_set(__new_start, __new_finish, __new_start + __len);
}
コード例 #4
0
ファイル: _vector.c プロジェクト: RenEvo/dead6
_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;
}