Quellcode durchsuchen

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

greatbridf vor 2 Jahren
Ursprung
Commit
082d9bd19a
1 geänderte Dateien mit 6 neuen und 2 gelöschten Zeilen
  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