https://gcc.gnu.org/g:771fcb9fe9b3fce8336a797c03c399a63e11eb21
commit r15-9752-g771fcb9fe9b3fce8336a797c03c399a63e11eb21 Author: Patrick Palka <ppa...@redhat.com> Date: Thu May 29 10:12:23 2025 -0400 libstdc++: Compare keys and values separately in flat_map::operator== Instead of effectively doing a zipped comparison of the keys and values, compare them separately to leverage the underlying containers' optimized equality implementations. libstdc++-v3/ChangeLog: * include/std/flat_map (_Flat_map_impl::operator==): Compare keys and values separately. Reviewed-by: Jonathan Wakely <jwak...@redhat.com> (cherry picked from commit ad96f0344adfc847874b34b43f30371979ae9963) Diff: --- libstdc++-v3/include/std/flat_map | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libstdc++-v3/include/std/flat_map b/libstdc++-v3/include/std/flat_map index cec7f36cff9f..4bd4963c2ad7 100644 --- a/libstdc++-v3/include/std/flat_map +++ b/libstdc++-v3/include/std/flat_map @@ -873,7 +873,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION [[nodiscard]] friend bool operator==(const _Derived& __x, const _Derived& __y) - { return std::equal(__x.begin(), __x.end(), __y.begin(), __y.end()); } + { + return __x._M_cont.keys == __y._M_cont.keys + && __x._M_cont.values == __y._M_cont.values; + } template<typename _Up = value_type> [[nodiscard]]