avoid operator!= ambiguity in c++20 (#1544)
Summary: F14 map `iterator` doesn't define `operator==` or `operator!=` to itself. Those member functions take `const_iterator` as the right-hand side, relying on the ability to convert implicitly from `iterator` to `const_iterator`. This interacts poorly with c++20's default equality operators, triggering clang's `-Wambiguous-reversed-operator`. This diff replaces the equality member functions with friends that use the same left-hand and right-hand types. iterator != const_iterator will now compile by implicitly converting the left-hand-side and then calling `operator!=(const_iterator const&, const_iterator const&)`, rather than calling `iterator::operator!=(const_iterator const&)`. This resolves the ambiguity in c++20, and should work fine on earlier versions, although I have not tested it on anything except c++17. Pull Request resolved: https://github.com/facebook/folly/pull/1544 Test Plan: does it build? Reviewed By: yfeldblum Differential Revision: D27479086 Pulled By: shixiao fbshipit-source-id: 0d42dbdc056cec58a36de3a816883736a761d0f6
Showing
Please register or sign in to comment