Skip to content

Commit

Permalink
fix(list): fix iterator::operator=(const self&)
Browse files Browse the repository at this point in the history
  • Loading branch information
1nchy committed Sep 29, 2023
1 parent a148388 commit ba58bea
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions list_node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ template <typename _Tp> struct list_iterator {
list_iterator(lnode* n): _ptr(n) {}
list_iterator(const self& rhs): _ptr(rhs._ptr) {}
self& operator=(const self& rhs) {
if (&rhs == this) return *this;
_ptr = rhs._ptr;
return *this;
}
Expand Down Expand Up @@ -148,7 +149,9 @@ template <typename _Tp> struct list_const_iterator {
list_const_iterator(const self& rhs): _ptr(rhs._ptr) {}
list_const_iterator(const iterator& rhs): _ptr(rhs._ptr) {}
self& operator=(const self& rhs) {
if (&rhs == this) return *this;
_ptr = rhs._ptr;
return *this;
}

iterator _const_cast() const {
Expand Down

0 comments on commit ba58bea

Please sign in to comment.