[libcxx-commits] [libcxx] [libc++] Make sure `flat_map::key_compare` handle `boolean-testable` correctly (PR #132621)
Hewill Kang via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Mar 23 10:18:05 PDT 2025
https://github.com/hewillk updated https://github.com/llvm/llvm-project/pull/132621
>From e0f56c01092be3319f73d076e484640feb8dd22c Mon Sep 17 00:00:00 2001
From: Hewill Kang <hewillk at gmail.com>
Date: Mon, 24 Mar 2025 01:09:36 +0800
Subject: [PATCH 1/2] [libc++] Make sure compare handle boolean-testable
correctly
---
libcxx/include/__flat_map/flat_map.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libcxx/include/__flat_map/flat_map.h b/libcxx/include/__flat_map/flat_map.h
index a0594ed9dc411..2f32497ab20d3 100644
--- a/libcxx/include/__flat_map/flat_map.h
+++ b/libcxx/include/__flat_map/flat_map.h
@@ -846,7 +846,7 @@ class flat_map {
__compare_(std::forward<_CompArg>(__comp)...) {}
_LIBCPP_HIDE_FROM_ABI bool __is_sorted_and_unique(auto&& __key_container) const {
- auto __greater_or_equal_to = [this](const auto& __x, const auto& __y) { return !__compare_(__x, __y); };
+ auto __greater_or_equal_to = [this](const auto& __x, const auto& __y) -> bool { return !__compare_(__x, __y); };
return ranges::adjacent_find(__key_container, __greater_or_equal_to) == ranges::end(__key_container);
}
@@ -870,7 +870,7 @@ class flat_map {
auto __zv = ranges::views::zip(__containers_.keys, __containers_.values);
auto __append_start_offset = __containers_.keys.size() - __num_of_appended;
auto __end = __zv.end();
- auto __compare_key = [this](const auto& __p1, const auto& __p2) {
+ auto __compare_key = [this](const auto& __p1, const auto& __p2) -> bool {
return __compare_(std::get<0>(__p1), std::get<0>(__p2));
};
if constexpr (!_WasSorted) {
>From 436ae2ed9977bf87c4e5b5b04cc13477416f20db Mon Sep 17 00:00:00 2001
From: Hewill Kang <hewillk at gmail.com>
Date: Mon, 24 Mar 2025 01:17:57 +0800
Subject: [PATCH 2/2] [libc++] Make sure compare handle boolean-testable
correctly
---
libcxx/include/__flat_map/flat_multimap.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libcxx/include/__flat_map/flat_multimap.h b/libcxx/include/__flat_map/flat_multimap.h
index ea77fb5d79bd2..664dc0eed1bb6 100644
--- a/libcxx/include/__flat_map/flat_multimap.h
+++ b/libcxx/include/__flat_map/flat_multimap.h
@@ -777,7 +777,7 @@ class flat_multimap {
auto __zv = ranges::views::zip(__containers_.keys, __containers_.values);
auto __append_start_offset = __containers_.keys.size() - __num_appended;
auto __end = __zv.end();
- auto __compare_key = [this](const auto& __p1, const auto& __p2) {
+ auto __compare_key = [this](const auto& __p1, const auto& __p2) -> bool {
return __compare_(std::get<0>(__p1), std::get<0>(__p2));
};
if constexpr (!_WasSorted) {
More information about the libcxx-commits
mailing list