Let self_return_iterator::operator== use an implicit T::operator==

This commit is contained in:
Kp 2022-12-10 18:09:54 +00:00
parent a00a1ce59a
commit 3ef8cb1e14

View file

@ -94,16 +94,16 @@ public:
{ {
return static_cast<self_return_iterator &>(this->T::operator--()); return static_cast<self_return_iterator &>(this->T::operator--());
} }
/* Since `T` is inherited privately, the base class `operator==` and /* Since `T` is inherited privately, the base class `operator==` cannot
* `operator!=` cannot implicitly convert `rhs` to `T`. Define * implicitly convert `rhs` to `T`. Explicitly cast to the base class,
* comparison operators to perform the conversion explicitly. * then invoke the comparison operator to perform the conversion.
*/ */
bool operator==(const self_return_iterator &rhs) const constexpr bool operator==(const self_return_iterator &rhs) const
{ {
return this->T::operator==(static_cast<const T &>(rhs)); return static_cast<const T &>(*this) == static_cast<const T &>(rhs);
} }
bool operator!=(const self_return_iterator &rhs) const constexpr bool operator!=(const self_return_iterator &rhs) const
{ {
return this->T::operator!=(static_cast<const T &>(rhs)); return static_cast<const T &>(*this) != static_cast<const T &>(rhs);
} }
}; };