From e63a5a61045e516b7b3dbca090e2b9ff1d057e46 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Thu, 8 Oct 2020 08:27:41 -0700 Subject: Export of internal Abseil changes -- 430bda42820b619b346201bc42769d014228e825 by Gennadiy Rozental : Update version for CMake and Bazel PiperOrigin-RevId: 336089889 -- 0a36f989acb0e6f7d2f04039c600b0934c44ffed by Abseil Team : changes how non-equality is evaluated absl::c_mismatch is based on std::mismatch, which requires that its iterators' reference types meet the requirements of Cpp17EqualityComparable[1]. The previous CL mistakenly wrote absl::c_mismatch using `*first1 != *first2` which assumes that the reference types model std::equality_comparable[2] (which was only added in C++20). This CL reverts that behaviour. [0]: http://wg21.link/mismatch [1]: http://wg21.link/utility.arg.requirements#tab:cpp17.equalitycomparable [2]: http://wg21.link/concept.equalitycomparable PiperOrigin-RevId: 335897465 -- 7cb902f079838081a15f8b72e0cef46beab653f2 by Derek Mauro : Disable a raw_hash_map_allocator.cc test that doesn't build due to a noexcept bug in gcc 5.4 and 5.5 PiperOrigin-RevId: 335876843 GitOrigin-RevId: 430bda42820b619b346201bc42769d014228e825 Change-Id: I94d5b8e03e0a91d81923aa831f6f63c625e0b836 --- absl/algorithm/container.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'absl/algorithm/container.h') diff --git a/absl/algorithm/container.h b/absl/algorithm/container.h index 3c4fd733..bb3d1c7c 100644 --- a/absl/algorithm/container.h +++ b/absl/algorithm/container.h @@ -351,7 +351,9 @@ c_mismatch(C1& c1, C2& c2) { auto last2 = container_algorithm_internal::c_end(c2); for (; first1 != last1 && first2 != last2; ++first1, (void)++first2) { - if (*first1 != *first2) { + // Negates equality because Cpp17EqualityComparable doesn't require clients + // to overload both `operator==` and `operator!=`. + if (!(*first1 == *first2)) { break; } } -- cgit v1.2.3