Example #1
0
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);
}
Example #2
0
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);
}
Example #3
0
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);
}
Example #4
0
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);
  }
}
Example #5
0
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);
  }
}
Example #6
0
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);
}