ソースを参照

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

greatbridf 2 年 前
コミット
082d9bd19a
1 ファイル変更6 行追加2 行削除
  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