소스 검색

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