add tests for vector assign iterator, and tests script
This commit is contained in:
@@ -155,7 +155,10 @@ VT_TPL void VT::
|
||||
******************/
|
||||
// operator[] --------------------------------
|
||||
VT_TPL typename VT::reference VT::
|
||||
operator[](size_type n) { return _mem_ptr[n]; }
|
||||
operator[](size_type n)
|
||||
{
|
||||
return _mem_ptr[n];
|
||||
}
|
||||
//const_reference operator[](size_type n) const;
|
||||
// at ----------------------------------------
|
||||
//reference at(size_type n);
|
||||
@@ -175,35 +178,25 @@ VT_TPL template <class InputIterator>
|
||||
typename enable_if< !is_integral<InputIterator>::value,void >::type VT::
|
||||
assign( InputIterator first, InputIterator last)
|
||||
{
|
||||
// TMP
|
||||
std::cout << B_RED "inside assign(first, last) " RESET;
|
||||
// TMP END
|
||||
InputIterator tmp = first;
|
||||
int range;
|
||||
int range = 0;
|
||||
|
||||
clear();
|
||||
|
||||
for (range = 1; tmp != last; range++)
|
||||
tmp++;
|
||||
while (tmp++ != last)
|
||||
range++;
|
||||
_size += range;
|
||||
if (_size >= _capacity)
|
||||
reserve(_size);
|
||||
while (first != last)
|
||||
{
|
||||
_allocator.construct(&_mem_ptr[_size], first);
|
||||
_allocator.construct(&_mem_ptr[_size], *first);
|
||||
first++;
|
||||
}
|
||||
}
|
||||
|
||||
// VT_TPL typename enable_if< isinteger<T>::value,std::string >::type VT::
|
||||
//VT_TPL template <class InputIterator>
|
||||
//typename enable_if< is_integral<InputIterator>::value,void >::type VT::
|
||||
VT_TPL void VT::
|
||||
assign( size_type n, const T & val )
|
||||
{
|
||||
// TMP
|
||||
std::cout << B_RED "inside assign(n, val) " RESET;
|
||||
// TMP END
|
||||
if (n > _allocator.max_size())
|
||||
throw std::length_error("assign: n > max_size");
|
||||
|
||||
@@ -237,7 +230,12 @@ VT_TPL void VT::
|
||||
_size++;
|
||||
}
|
||||
// pop_back ----------------------------------
|
||||
//void pop_back();
|
||||
VT_TPL void VT::
|
||||
pop_back()
|
||||
{
|
||||
_allocator.destroy(end() - 1);
|
||||
_size--;
|
||||
}
|
||||
// insert ------------------------------------
|
||||
//iterator insert(iterator position, const value_type& val);
|
||||
//void insert(iterator position, size_type n, const value_type& val);
|
||||
|
||||
Reference in New Issue
Block a user