From 3ef8cb1e14e49c8fe60bea5e7c90f7d761a7202f Mon Sep 17 00:00:00 2001 From: Kp Date: Sat, 10 Dec 2022 18:09:54 +0000 Subject: [PATCH] Let self_return_iterator::operator== use an implicit T::operator== --- common/main/selfiter.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) 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); } };