diff --git a/common/main/selfiter.h b/common/main/selfiter.h index 0719d6596..6847d8dba 100644 --- a/common/main/selfiter.h +++ b/common/main/selfiter.h @@ -94,16 +94,16 @@ public: { return static_cast(this->T::operator--()); } - /* Since `T` is inherited privately, the base class `operator==` and - * `operator!=` cannot implicitly convert `rhs` to `T`. Define - * comparison operators to perform the conversion explicitly. + /* Since `T` is inherited privately, the base class `operator==` cannot + * implicitly convert `rhs` to `T`. Explicitly cast to the base class, + * 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(rhs)); + return static_cast(*this) == static_cast(rhs); } - bool operator!=(const self_return_iterator &rhs) const + constexpr bool operator!=(const self_return_iterator &rhs) const { - return this->T::operator!=(static_cast(rhs)); + return static_cast(*this) != static_cast(rhs); } };