[libcxx-commits] [libcxx] [libc++] Make sure `flat_map::key_compare` handle `boolean-testable` correctly (PR #132621)

via libcxx-commits libcxx-commits at lists.llvm.org
Sun Mar 23 10:13:41 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libcxx

Author: Hewill Kang (hewillk)

<details>
<summary>Changes</summary>

This is sibling of [#<!-- -->69378](https://github.com/llvm/llvm-project/pull/69378).

---
Full diff: https://github.com/llvm/llvm-project/pull/132621.diff


1 Files Affected:

- (modified) libcxx/include/__flat_map/flat_map.h (+2-2) 


``````````diff
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) {

``````````

</details>


https://github.com/llvm/llvm-project/pull/132621


More information about the libcxx-commits mailing list