diff --git a/include/const_list.h b/include/const_list.h index 3329419..9dace87 100644 --- a/include/const_list.h +++ b/include/const_list.h @@ -256,11 +256,12 @@ namespace cc { } _tail = std::move(other._tail); + _tail._owner = this; } template constexpr const_list::const_list(std::initializer_list> 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::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; }