implemented push/pop_back/front for const_list

This commit is contained in:
cyborg1811m 2024-02-04 23:21:10 +01:00
parent 09ba7d5783
commit fc59dd2404
1 changed files with 31 additions and 13 deletions

View File

@ -137,21 +137,11 @@ namespace cc {
constexpr iterator erase(const_iterator pos);
constexpr iterator erase(const_iterator first, const_iterator last);
constexpr void push_back(const value_type& value);
constexpr void push_back(value_type&& value);
template<typename ...Args>
constexpr reference emplace_back(Args&&... args);
constexpr void push_back(value_type& value);
constexpr void pop_back();
constexpr void push_front(const value_type& value);
constexpr void push_front(value_type&& value);
template<typename ...Args>
constexpr reference emplace_front(Args&&... args);
constexpr void pop_front();
constexpr void push_front(value_type& value);
constexpr void pop_front();
constexpr void resize(size_type count);
constexpr void resize(size_type count, const value_type& value);
@ -387,6 +377,34 @@ namespace cc {
return next;
}
template<typename Node>
constexpr void const_list<Node>::push_back(value_type &value)
{
_tail.push_before(std::addressof(value));
++_size;
}
template<typename Node>
constexpr void const_list<Node>::pop_back()
{
_tail._prev->unlink();
--_size;
}
template<typename Node>
constexpr void const_list<Node>::push_front(value_type &value)
{
_tail._next->push_before(std::addressof(value));
++_size;
}
template<typename Node>
constexpr void const_list<Node>::pop_front()
{
_tail._next->unlink();
--_size;
}
template<typename D>
constexpr const_list_node<D>::const_list_node(const const_list_node &other) noexcept
: _delete_cb(other._delete_cb)