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