diff --git a/include/libcamera/base/utils.h b/include/libcamera/base/utils.h
index c4a06660..780aeda6 100644
--- a/include/libcamera/base/utils.h
+++ b/include/libcamera/base/utils.h
@@ -205,9 +205,14 @@ public:
 		iterator &operator++();
 		std::string operator*() const;
 
+		bool operator==(const iterator &other) const
+		{
+			return pos_ == other.pos_;
+		}
+
 		bool operator!=(const iterator &other) const
 		{
-			return pos_ != other.pos_;
+			return !(*this == other);
 		}
 
 	private:
