bug fix
This commit is contained in:
@@ -151,7 +151,7 @@ namespace TinySTL{
|
|||||||
void destroyAndDeallocateAll(){
|
void destroyAndDeallocateAll(){
|
||||||
if (capacity() != 0){
|
if (capacity() != 0){
|
||||||
dataAllocator::destroy(start_, finish_);
|
dataAllocator::destroy(start_, finish_);
|
||||||
dataAllocator::deallocate(start_, endOfStorage_ - start_);
|
dataAllocator::deallocate(start_, capacity());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void allocateAndFillN(const size_type n, const value_type& value){
|
void allocateAndFillN(const size_type n, const value_type& value){
|
||||||
@@ -181,10 +181,10 @@ namespace TinySTL{
|
|||||||
template<class InputIterator>
|
template<class InputIterator>
|
||||||
void reallocateAndCopy(iterator position, InputIterator first, InputIterator last);
|
void reallocateAndCopy(iterator position, InputIterator first, InputIterator last);
|
||||||
void reallocateAndFillN(iterator position, const size_type& n, const value_type& val);
|
void reallocateAndFillN(iterator position, const size_type& n, const value_type& val);
|
||||||
difference_type getNewCapacity(difference_type len)const{
|
size_type getNewCapacity(size_type len)const{
|
||||||
difference_type oldCapacity = endOfStorage_ - start_;
|
size_type oldCapacity = endOfStorage_ - start_;
|
||||||
oldCapacity = oldCapacity ? oldCapacity : 1;
|
auto res = std::max(oldCapacity, len);
|
||||||
difference_type newCapacity = oldCapacity + std::max(oldCapacity, len);
|
size_type newCapacity = (oldCapacity != 0 ? (oldCapacity + res) : 1);
|
||||||
return newCapacity;
|
return newCapacity;
|
||||||
}
|
}
|
||||||
};// end of class vector
|
};// end of class vector
|
||||||
@@ -294,6 +294,7 @@ namespace TinySTL{
|
|||||||
template<class T, class Alloc>
|
template<class T, class Alloc>
|
||||||
template<class Integer>
|
template<class Integer>
|
||||||
void vector<T, Alloc>::insert_aux(iterator position, Integer n, Integer value, std::true_type){
|
void vector<T, Alloc>::insert_aux(iterator position, Integer n, Integer value, std::true_type){
|
||||||
|
assert(n != 0);
|
||||||
difference_type locationLeft = endOfStorage_ - finish_; // the size of left storage
|
difference_type locationLeft = endOfStorage_ - finish_; // the size of left storage
|
||||||
difference_type locationNeed = n;
|
difference_type locationNeed = n;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user