Index: uspace/lib/cpp/include/impl/list.hpp
===================================================================
--- uspace/lib/cpp/include/impl/list.hpp	(revision 2e53e83dc4427db3eef5f878668129f8f5f0186a)
+++ uspace/lib/cpp/include/impl/list.hpp	(revision bb1d15c4eeb534c4ffc789406cf5423acbe8a00a)
@@ -30,6 +30,7 @@
 #define LIBCPP_LIST
 
+#include <__bits/insert_iterator.hpp>
+#include <__bits/list.hpp>
 #include <cstdlib>
-#include <__bits/list.hpp>
 #include <iterator>
 #include <memory>
@@ -43,4 +44,7 @@
     namespace aux
     {
+        template<class T>
+        class list_iterator;
+
         template<class T>
         class list_const_iterator
@@ -53,9 +57,10 @@
                 using size_type       = typename list<T>::size_type;
 
-                using iterator_category = forward_iterator_tag;
+                using iterator_category = bidirectional_iterator_tag;
 
                 list_const_iterator(list_node<value_type>* node = nullptr,
-                                    list_node<value_type>* head = nullptr)
-                    : current_{node}, head_{head}
+                                    list_node<value_type>* head = nullptr,
+                                    bool end = true)
+                    : current_{node}, head_{head}, end_{end}
                 { /* DUMMY BODY */ }
 
@@ -65,4 +70,8 @@
                 list_const_iterator& operator=(list_const_iterator&&) = default;
 
+                list_const_iterator(const list_iterator<T>& other)
+                    : current_{other.current_}, head_{other.head_}
+                { /* DUMMY BODY */ }
+
                 reference operator*() const
                 {
@@ -72,8 +81,8 @@
                 list_const_iterator& operator++()
                 {
-                    if (current_)
+                    if (!end_ && current_)
                     {
                         if (current_->next == head_)
-                            current_ = nullptr;
+                            end_ = true;
                         else
                             current_ = current_->next;
@@ -85,15 +94,31 @@
                 list_const_iterator operator++(int)
                 {
-                    auto bckp = current_;
-
-                    if (current_)
+                    auto old = *this;
+                    ++(*this);
+
+                    return old;
+                }
+
+                list_const_iterator& operator--()
+                {
+                    if (end_)
+                        end_ = false;
+                    else if (current_)
                     {
-                        if (current_->next == head_)
-                            current_ = nullptr;
+                        if (current_ != head_)
+                            current_ = current_->prev;
                         else
-                            current_ = current_->next;
+                            end_ = true;
                     }
 
-                    return list_const_iterator{bckp};
+                    return *this;
+                }
+
+                list_const_iterator operator--(int)
+                {
+                    auto old = *this;
+                    --(*this);
+
+                    return old;
                 }
 
@@ -123,7 +148,13 @@
                 }
 
+                bool end() const
+                {
+                    return end_;
+                }
+
             private:
                 list_node<value_type>* current_;
                 list_node<value_type>* head_;
+                bool end_;
         };
 
@@ -131,5 +162,5 @@
         bool operator==(const list_const_iterator<T>& lhs, const list_const_iterator<T>& rhs)
         {
-            return lhs.node() == rhs.node();
+            return (lhs.node() == rhs.node()) && (lhs.end() == rhs.end());
         }
 
@@ -150,9 +181,10 @@
                 using size_type       = typename list<T>::size_type;
 
-                using iterator_category = forward_iterator_tag;
+                using iterator_category = bidirectional_iterator_tag;
 
                 list_iterator(list_node<value_type>* node = nullptr,
-                              list_node<value_type>* head = nullptr)
-                    : current_{node}, head_{head}
+                              list_node<value_type>* head = nullptr,
+                              bool end = true)
+                    : current_{node}, head_{head}, end_{end}
                 { /* DUMMY BODY */ }
 
@@ -162,5 +194,5 @@
                 list_iterator& operator=(list_iterator&&) = default;
 
-                reference operator*()
+                reference operator*() const
                 {
                     return current_->value;
@@ -169,8 +201,8 @@
                 list_iterator& operator++()
                 {
-                    if (current_)
+                    if (!end_ && current_)
                     {
                         if (current_->next == head_)
-                            current_ = nullptr;
+                            end_ = true;
                         else
                             current_ = current_->next;
@@ -182,15 +214,31 @@
                 list_iterator operator++(int)
                 {
-                    auto bckp = current_;
-
-                    if (current_)
+                    auto old = *this;
+                    ++(*this);
+
+                    return old;
+                }
+
+                list_iterator& operator--()
+                {
+                    if (end_)
+                        end_ = false;
+                    else if (current_)
                     {
-                        if (current_->next == head_)
-                            current_ = nullptr;
+                        if (current_ != head_)
+                            current_ = current_->prev;
                         else
-                            current_ = current_->next;
+                            end_ = true;
                     }
 
-                    return list_iterator{bckp};
+                    return *this;
+                }
+
+                list_iterator operator--(int)
+                {
+                    auto old = *this;
+                    --(*this);
+
+                    return old;
                 }
 
@@ -225,7 +273,13 @@
                 }
 
+                bool end() const
+                {
+                    return end_;
+                }
+
             private:
                 list_node<value_type>* current_;
                 list_node<value_type>* head_;
+                bool end_;
         };
 
@@ -233,5 +287,5 @@
         bool operator==(const list_iterator<T>& lhs, const list_iterator<T>& rhs)
         {
-            return lhs.node() == rhs.node();
+            return (lhs.node() == rhs.node()) && (lhs.end() == rhs.end());
         }
 
@@ -283,6 +337,6 @@
             {
                 init_(
-                    aux::insert_iterator<value_type>{value_type{}},
-                    aux::insert_iterator<value_type>{size_}
+                    aux::insert_iterator<value_type>{size_type{}, value_type{}},
+                    aux::insert_iterator<value_type>{size_, value_type{}}
                 );
             }
@@ -293,6 +347,6 @@
             {
                 init_(
-                    aux::insert_iterator<value_type>{val},
-                    aux::insert_iterator<value_type>{n}
+                    aux::insert_iterator<value_type>{size_type{}, val},
+                    aux::insert_iterator<value_type>{n, value_type{}}
                 );
             }
@@ -316,9 +370,10 @@
             {
                 other.head_ = nullptr;
+                other.size_ = size_type{};
             }
 
             list(const list& other, const allocator_type alloc)
-                : allocator_{alloc}, head_{nullptr}, size_{other.size_}
-            {
+                : allocator_{alloc}, head_{nullptr}, size_{}
+            { // Size is set in init_.
                 init_(other.begin(), other.end());
             }
@@ -330,4 +385,5 @@
             {
                 other.head_ = nullptr;
+                other.size_ = size_type{};
             }
 
@@ -350,4 +406,6 @@
 
                 init_(other.begin(), other.end());
+
+                return *this;
             }
 
@@ -357,10 +415,12 @@
                 fini_();
 
+                head_ = move(other.head_);
+                size_ = move(other.size_);
                 allocator_ = move(other.allocator_);
 
-                init_(
-                    make_move_iterator(other.begin()),
-                    make_move_iterator(other.end())
-                );
+                other.head_ = nullptr;
+                other.size_ = size_type{};
+
+                return *this;
             }
 
@@ -370,4 +430,6 @@
 
                 init_(init.begin(), init.end());
+
+                return *this;
             }
 
@@ -385,6 +447,6 @@
 
                 init_(
-                    aux::insert_iterator<value_type>{val},
-                    aux::insert_iterator<value_type>{n}
+                    aux::insert_iterator<value_type>{size_type{}, val},
+                    aux::insert_iterator<value_type>{n, value_type{}}
                 );
             }
@@ -404,5 +466,5 @@
             iterator begin() noexcept
             {
-                return iterator{head_, head_};
+                return iterator{head_, head_, size_ == 0U};
             }
 
@@ -414,5 +476,5 @@
             iterator end() noexcept
             {
-                return iterator{nullptr, head_};
+                return iterator{get_last_(), head_, true};
             }
 
@@ -444,10 +506,10 @@
             const_iterator cbegin() const noexcept
             {
-                return const_iterator{head_, head_};
+                return const_iterator{head_, head_, size_ == 0U};
             }
 
             const_iterator cend() const noexcept
             {
-                return const_iterator{nullptr, head_};
+                return const_iterator{get_last_(), head_, true};
             }
 
@@ -608,5 +670,5 @@
                     head_ = head_->prev;
 
-                return iterator{node->prev, head_};
+                return iterator{node->prev, head_, false};
             }
 
@@ -625,6 +687,6 @@
                 return insert(
                     position,
-                    aux::insert_iterator<value_type>{0u, val},
-                    aux::insert_iterator<value_type>{n}
+                    aux::insert_iterator<value_type>{size_type{}, val},
+                    aux::insert_iterator<value_type>{n, value_type{}}
                 );
             }
@@ -642,5 +704,5 @@
                 }
 
-                return iterator{position.node()->next, head_};
+                return iterator{position.node()->next, head_, false};
             }
 
@@ -675,5 +737,5 @@
                 delete node;
 
-                return iterator{next, head_};
+                return iterator{next, head_, size_ == 0U};
             }
 
@@ -703,5 +765,5 @@
                 }
 
-                return iterator{next, head_};
+                return iterator{next, head_, size_ == 0U};
             }
 
@@ -1033,5 +1095,5 @@
             }
 
-            aux::list_node<value_type>* get_last_()
+            aux::list_node<value_type>* get_last_() const
             {
                 if (!head_)
