fixed erase()
This commit is contained in:
parent
cfb82ca1fe
commit
9cbeacef21
|
|
@ -486,22 +486,29 @@ namespace cc {
|
||||||
template<typename T, std::size_t N>
|
template<typename T, std::size_t N>
|
||||||
constexpr const_vector<T, N>::iterator const_vector<T, N>::erase(const_vector::const_iterator pos)
|
constexpr const_vector<T, N>::iterator const_vector<T, N>::erase(const_vector::const_iterator pos)
|
||||||
{
|
{
|
||||||
_erase_no_move(pos);
|
auto it = const_cast<iterator>(pos);
|
||||||
std::move(pos + 1, end(), pos);
|
|
||||||
|
std::destroy_n(it, 1);
|
||||||
|
std::move(it + 1, end(), it);
|
||||||
--_size;
|
--_size;
|
||||||
|
|
||||||
return pos;
|
return it;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, std::size_t N>
|
template<typename T, std::size_t N>
|
||||||
constexpr const_vector<T, N>::iterator
|
constexpr const_vector<T, N>::iterator
|
||||||
const_vector<T, N>::erase(const_vector::const_iterator first, const_vector::const_iterator last)
|
const_vector<T, N>::erase(const_vector::const_iterator first, const_vector::const_iterator last)
|
||||||
{
|
{
|
||||||
_erase_no_move(first, last);
|
auto _first = const_cast<iterator>(first);
|
||||||
std::move(last + 1, end(), first);
|
auto _last = const_cast<iterator>(last);
|
||||||
_size -= (last - first);
|
|
||||||
|
|
||||||
return first;
|
if (_first == _last) return _last;
|
||||||
|
|
||||||
|
std::destroy(_first, _last);
|
||||||
|
std::move(_last, end(), _first);
|
||||||
|
_size -= std::distance(_first, _last);
|
||||||
|
|
||||||
|
return _first;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, std::size_t N>
|
template<typename T, std::size_t N>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue