const_list: bugfix of splice all and owner of tail nodes
This commit is contained in:
parent
8de4b1a3c4
commit
51d140274a
|
|
@ -256,11 +256,12 @@ namespace cc {
|
||||||
}
|
}
|
||||||
|
|
||||||
_tail = std::move(other._tail);
|
_tail = std::move(other._tail);
|
||||||
|
_tail._owner = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Node>
|
template<typename Node>
|
||||||
constexpr const_list<Node>::const_list(std::initializer_list<std::reference_wrapper<value_type>> init) noexcept
|
constexpr const_list<Node>::const_list(std::initializer_list<std::reference_wrapper<value_type>> init) noexcept
|
||||||
: _tail(),
|
: _tail(this),
|
||||||
_size(init.size())
|
_size(init.size())
|
||||||
{
|
{
|
||||||
asserts();
|
asserts();
|
||||||
|
|
@ -282,6 +283,7 @@ namespace cc {
|
||||||
}
|
}
|
||||||
|
|
||||||
_tail = std::move(other._tail);
|
_tail = std::move(other._tail);
|
||||||
|
_tail._owner = this;
|
||||||
_size = other._size;
|
_size = other._size;
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
|
|
@ -504,13 +506,17 @@ namespace cc {
|
||||||
value._owner = this;
|
value._owner = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
pos->_prev->_next = other._tail->_next;
|
auto p = pos._const_cast();
|
||||||
pos->_prev = other._tail->_prev;
|
|
||||||
|
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;
|
_size += other._size;
|
||||||
|
|
||||||
other._tail->_prev = &other._tail;
|
other._tail._prev = &other._tail;
|
||||||
other._tail->_next = &other._tail;
|
other._tail._next = &other._tail;
|
||||||
other._size = 0;
|
other._size = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -524,8 +530,10 @@ namespace cc {
|
||||||
value._owner = this;
|
value._owner = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
pos->_prev->_next = other._tail->_next;
|
auto p = pos._const_cast();
|
||||||
pos->_prev = other._tail->_prev;
|
|
||||||
|
p._node->_prev->_next = other._tail->_next;
|
||||||
|
p._node->_prev = other._tail->_prev;
|
||||||
|
|
||||||
_size += other._size;
|
_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)
|
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
|
// 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;
|
++_size;
|
||||||
--other._size;
|
--other._size;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue