Move comparison operator out of class

This commit is contained in:
Chocobo1
2022-04-04 15:10:19 +08:00
parent 9318f05e2b
commit 39c34078d6
4 changed files with 66 additions and 59 deletions

View File

@@ -101,14 +101,15 @@ public:
return iter;
}
constexpr bool operator==(const Iterator &other) const
// comparing iterators from different containers is undefined behavior in C++ standard library
friend constexpr bool operator==(const Iterator &left, const Iterator &right)
{
return (*(*this) == *other);
return (*left == *right);
}
constexpr bool operator!=(const Iterator &other) const
friend constexpr bool operator!=(const Iterator &left, const Iterator &right)
{
return !(*this == other);
return !(left == right);
}
private: