Skip to content

[libc++] Make sure flat_set::key_compare handle boolean-testable correctly #132622

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

hewillk
Copy link
Contributor

@hewillk hewillk commented Mar 23, 2025

No description provided.

@hewillk hewillk requested a review from a team as a code owner March 23, 2025 17:23
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Mar 23, 2025
@llvmbot
Copy link
Member

llvmbot commented Mar 23, 2025

@llvm/pr-subscribers-libcxx

Author: Hewill Kang (hewillk)

Changes

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

1 Files Affected:

  • (modified) libcxx/include/__flat_set/flat_set.h (+1-1)
diff --git a/libcxx/include/__flat_set/flat_set.h b/libcxx/include/__flat_set/flat_set.h
index cc45db7565bd4..9074e9e9cf241 100644
--- a/libcxx/include/__flat_set/flat_set.h
+++ b/libcxx/include/__flat_set/flat_set.h
@@ -602,7 +602,7 @@ class flat_set {
 
 private:
   _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);
   }
 

Copy link
Member

@ldionne ldionne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the patch! Can you please add a test for this?

@hewillk
Copy link
Contributor Author

hewillk commented Apr 11, 2025

flat_multiset has the same issue, so this PR should also deal with flat_multiset.
But let me familiarize myself with the contribution steps of llvm first...

@huixie90 huixie90 self-assigned this May 12, 2025
Copy link
Contributor

@huixie90 huixie90 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added test to your branch. However, I noticed that in your branch the flat_multiset is not implemented. Could you please rebase main, updated the source code for flat_multiset and probably add the test that is similar to the test that I added for flat_set?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants