https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115939
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> --- Created attachment 58668 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58668&action=edit Add operator== overloads for hash table iterators (In reply to Jonathan Wakely from comment #1) > Secondly, we could add operator== for the actual iterator type, so that > there's no derived-to-base conversion needed to find a candidate. This patch implements this change. The new operator== overloads are exact matches, so no derived-to-base or user-defined conversions are required. I'll get to work on the std::expected proposal (which I expect will get treated as a DR for C++23 by all implementers, certainly in libstdc++). Once I've drafted that proposal, I'll push the corresponding code changes to libstdc++. N.B. this slightly modified example shows why the patch needs so many new overloads: #include <any> #include <expected> #include <unordered_map> struct Y {}; std::unordered_map<int, std::expected<std::any, Y>> m; bool r = m.begin()==m.cend(); Using m.cend() means we need overloads for comparing iterator to const_iterator (which is why the comparisons were defined on the base class in the first place, since they only need to be done once and they work for both iterator and const_iterator ... unless there is some other candidate that's viable).