Bladeren bron

fix(list): make _empty_list.begin() return end()

greatbridf 2 jaren geleden
bovenliggende
commit
082d9bd19a
1 gewijzigde bestanden met toevoegingen van 6 en 2 verwijderingen
  1. 6 2
      include/types/list.hpp

+ 6 - 2
include/types/list.hpp

@@ -313,7 +313,9 @@ public:
 
     constexpr iterator_type begin() noexcept
     {
-        return iterator_type(head->next);
+        if (head)
+            return iterator_type(head->next);
+        return end();
     }
 
     constexpr iterator_type end() noexcept
@@ -323,7 +325,9 @@ public:
 
     constexpr const_iterator_type begin() const noexcept
     {
-        return const_iterator_type(head->next);
+        if (head)
+            return const_iterator_type(head->next);
+        return end();
     }
 
     constexpr const_iterator_type end() const noexcept