made const_list compilable
This commit is contained in:
parent
9581f0028c
commit
6d9e70068c
|
|
@ -119,11 +119,11 @@ namespace cc {
|
|||
|
||||
constexpr void assign(std::initializer_list<std::reference_wrapper<value_type>> init) noexcept;
|
||||
|
||||
[[nodiscard]] constexpr reference front() noexcept{ return dynamic_cast<Node&>(_tail._next); }
|
||||
[[nodiscard]] constexpr const_reference front() const noexcept { return dynamic_cast<Node&>(_tail._next); }
|
||||
[[nodiscard]] constexpr reference front() noexcept{ return *dynamic_cast<Node*>(_tail._next); }
|
||||
[[nodiscard]] constexpr const_reference front() const noexcept { return *dynamic_cast<Node*>(_tail._next); }
|
||||
|
||||
[[nodiscard]] constexpr reference back() noexcept { return dynamic_cast<Node&>(_tail._prev); }
|
||||
[[nodiscard]] constexpr const_reference back() const noexcept { return dynamic_cast<Node&>(_tail._prev); }
|
||||
[[nodiscard]] constexpr reference back() noexcept { return *dynamic_cast<Node*>(_tail._prev); }
|
||||
[[nodiscard]] constexpr const_reference back() const noexcept { return *dynamic_cast<Node*>(_tail._prev); }
|
||||
|
||||
[[nodiscard]] constexpr iterator begin() noexcept { return iterator(_tail._next); };
|
||||
[[nodiscard]] constexpr const_iterator begin() const noexcept { return const_iterator(_tail._next); };
|
||||
|
|
@ -226,6 +226,9 @@ namespace cc {
|
|||
constexpr const_list_node(const_list_node&& other) noexcept;
|
||||
virtual constexpr ~const_list_node();
|
||||
|
||||
constexpr const_list_node<D>& operator=(const const_list_node& other) noexcept;
|
||||
constexpr const_list_node<D>& operator=(const_list_node&& other) noexcept;
|
||||
|
||||
protected:
|
||||
constexpr void on_delete(void (*cb)()) noexcept;
|
||||
|
||||
|
|
@ -274,14 +277,15 @@ namespace cc {
|
|||
|
||||
template<typename Node>
|
||||
constexpr const_list<Node>::const_list(const_list &&other) noexcept
|
||||
: _tail(std::move(other._tail)),
|
||||
_size(other._size)
|
||||
: _size(other._size)
|
||||
{
|
||||
asserts();
|
||||
|
||||
for (auto node : other) {
|
||||
for (auto& node : other) {
|
||||
node._owner = this;
|
||||
}
|
||||
|
||||
_tail = std::move(other._tail);
|
||||
}
|
||||
|
||||
template<typename Node>
|
||||
|
|
@ -327,6 +331,7 @@ namespace cc {
|
|||
|
||||
for (auto& value : init) {
|
||||
_tail.push_before(std::addressof(value.get()));
|
||||
value.get()._owner = this;
|
||||
}
|
||||
_size += init.size();
|
||||
}
|
||||
|
|
@ -380,6 +385,10 @@ namespace cc {
|
|||
{
|
||||
_prev->_next = this;
|
||||
_next->_prev = this;
|
||||
|
||||
// without this the destructor of other would delete moved nodes
|
||||
other._next = std::addressof(other);
|
||||
other._prev = std::addressof(other);
|
||||
}
|
||||
|
||||
template<typename D>
|
||||
|
|
@ -390,6 +399,29 @@ namespace cc {
|
|||
unlink();
|
||||
}
|
||||
|
||||
template<typename D>
|
||||
constexpr const_list_node<D> &const_list_node<D>::operator=(const const_list_node &other) noexcept
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename D>
|
||||
constexpr const_list_node<D> &const_list_node<D>::operator=(const_list_node &&other) noexcept
|
||||
{
|
||||
_prev = other._prev;
|
||||
_next = other._next;
|
||||
_delete_cb = other._delete_cb;
|
||||
|
||||
_prev->_next = this;
|
||||
_next->_prev = this;
|
||||
|
||||
// without this the destructor of other would delete moved nodes
|
||||
other._next = std::addressof(other);
|
||||
other._prev = std::addressof(other);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename D>
|
||||
constexpr void const_list_node<D>::on_delete(void (*cb)()) noexcept
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue