const_list: bugfix of splice all and owner of tail nodes

This commit is contained in:
cyborg1811m 2024-02-08 22:01:41 +01:00
parent 8de4b1a3c4
commit 51d140274a
1 changed files with 16 additions and 8 deletions

View File

@ -256,11 +256,12 @@ namespace cc {
}
_tail = std::move(other._tail);
_tail._owner = this;
}
template<typename Node>
constexpr const_list<Node>::const_list(std::initializer_list<std::reference_wrapper<value_type>> init) noexcept
: _tail(),
: _tail(this),
_size(init.size())
{
asserts();
@ -282,6 +283,7 @@ namespace cc {
}
_tail = std::move(other._tail);
_tail._owner = this;
_size = other._size;
return *this;
@ -504,13 +506,17 @@ namespace cc {
value._owner = this;
}
pos->_prev->_next = other._tail->_next;
pos->_prev = other._tail->_prev;
auto p = pos._const_cast();
p._node->_prev->_next = other._tail._next;
other._tail._next->_prev = p._node->_prev;
p._node->_prev = other._tail._prev;
other._tail._prev->_next = p._node;
_size += other._size;
other._tail->_prev = &other._tail;
other._tail->_next = &other._tail;
other._tail._prev = &other._tail;
other._tail._next = &other._tail;
other._size = 0;
}
@ -524,8 +530,10 @@ namespace cc {
value._owner = this;
}
pos->_prev->_next = other._tail->_next;
pos->_prev = other._tail->_prev;
auto p = pos._const_cast();
p._node->_prev->_next = other._tail->_next;
p._node->_prev = other._tail->_prev;
_size += other._size;
@ -538,7 +546,7 @@ namespace cc {
const_list<Node>::splice(const_list::const_iterator pos, const_list &other, const_list::const_iterator it)
{
// if it does point into other, then it has to have a size
pos._const_cast()->push_before(it._const_cast()._node);
pos._const_cast()._node->push_before(it._const_cast()._node);
++_size;
--other._size;
}