Commit 81ffb99f authored by Jan Koniarik's avatar Jan Koniarik
Browse files

moved iterators to operator<=> and operator==

parent 961e6c0e
Pipeline #93968 passed with stage
in 39 seconds
......@@ -82,10 +82,9 @@ class generic_iterator {
return copy;
}
constexpr bool operator<(const generic_iterator<Derived> &other) const {
return impl() < other.impl();
constexpr auto operator<=>(const generic_iterator<Derived> &other) const {
return impl() <=> other.impl();
}
constexpr bool operator==(const generic_iterator<Derived> &other) const {
return impl() == other.impl();
}
......@@ -103,31 +102,4 @@ class generic_iterator {
}
};
/// A > B iff B < A
template <typename Derived>
constexpr bool operator>(const generic_iterator<Derived> &lh, const generic_iterator<Derived> &rh) {
return rh < lh;
}
/// A <= B iff !( B > A )
template <typename Derived>
constexpr bool operator<=(const generic_iterator<Derived> &lh,
const generic_iterator<Derived> &rh) {
return !(lh > rh);
}
/// A >= B iff !( B < A )
template <typename Derived>
constexpr bool operator>=(const generic_iterator<Derived> &lh,
const generic_iterator<Derived> &rh) {
return !(lh < rh);
}
/// A != B iff !( A == B)
template <typename Derived>
constexpr bool operator!=(const generic_iterator<Derived> &lh,
const generic_iterator<Derived> &rh) {
return !(lh == rh);
}
} // namespace emlabcpp
......@@ -49,8 +49,8 @@ class access_iterator : public generic_iterator<access_iterator<Iterator, Access
return *this;
}
constexpr bool operator<(const access_iterator &other) const {
return current_ < other.current_;
constexpr auto operator<=>(const access_iterator &other) const {
return current_ <=> other.current_;
}
constexpr bool operator==(const access_iterator &other) const {
return current_ == other.current_;
......
......@@ -45,8 +45,10 @@ class numeric_iterator : public generic_iterator<numeric_iterator<T>> {
return *this;
}
constexpr bool operator<(const numeric_iterator &other) const { return val_ < other.val_; }
constexpr bool operator==(const numeric_iterator &other) const {
constexpr auto operator<=>(const numeric_iterator<T> &other) const {
return val_ <=> other.val_;
}
constexpr auto operator==(const numeric_iterator<T> &other) const {
return val_ == other.val_;
}
......
......@@ -51,7 +51,7 @@ class subscript_iterator : public generic_iterator<subscript_iterator<Container>
return *this;
}
bool operator<(const subscript_iterator &other) const { return i_ < other.i_; }
auto operator<=>(const subscript_iterator &other) const { return i_ <=> other.i_; }
bool operator==(const subscript_iterator &other) const {
return i_ == other.i_ && &cont_ == &other.cont_;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment