Написал код реализации(часть сам писал, часть подсмотрел в других темах). Ер есть баги. Подскажите где не правильно
Код | template <typename T, typename Allocator> typename Vector<T, Allocator>::iterator Vector<T, Allocator>::erase(iterator position) { for (int index = 0; index < size(); ++index) { if (&(array[index]) == position) { if (m_size == 1) { array[0] = T(); --m_size; return; } uninitialized_copy(index) array[m_size - 1] = T(); --m_size; return; } } }
template <typename T, typename Allocator> typename Vector<T, Allocator>::iterator Vector<T, Allocator>::erase(iterator first, iterator last) { for (; first != last; ++first) m_allocator.destroy(first); }[/CPP]
[size="1"][color="grey"][I]Добавлено через 50 секунд[/I][/color][/size] [CPP]#pragma once
template <typename T> void UninitializedCopy(const T* begin, const T* end, T* dest) { for (; begin != end; ++begin, ++dest) ::new (dest) T(*begin); }
template <typename T> void UninitializedCopyN(const T* begin, std::size_t count, T* dest) { for (; count > 0; --count, ++begin, ++dest) ::new (dest) T(*begin); }
template <typename T> void UninitializedFill(T* begin, T* end, const T& value) { for (; begin != end; ++begin) ::new (begin) T(value); }
template <typename T> void UninitializedFillN(T* begin, std::size_t count, const T& value) { for (; count > 0; --count, ++begin) ::new (begin) T(value); }[ |
|