Skip to content

Conversation

kazutakahirata
Copy link
Contributor

This patch simplifies the assertion by replacing the std::all_of check
with a more direct C++17 fold expression.

This patch simplifies the assertion by replacing the std::all_of check
with a more direct C++17 fold expression.
@llvmbot
Copy link
Member

llvmbot commented Oct 2, 2025

@llvm/pr-subscribers-llvm-adt

Author: Kazu Hirata (kazutakahirata)

Changes

This patch simplifies the assertion by replacing the std::all_of check
with a more direct C++17 fold expression.


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

1 Files Affected:

  • (modified) llvm/include/llvm/ADT/BitVector.h (+1-4)
diff --git a/llvm/include/llvm/ADT/BitVector.h b/llvm/include/llvm/ADT/BitVector.h
index 83350e6e45846..9e81a4b735e7f 100644
--- a/llvm/include/llvm/ADT/BitVector.h
+++ b/llvm/include/llvm/ADT/BitVector.h
@@ -570,10 +570,7 @@ class BitVector {
   template <class F, class... ArgTys>
   static BitVector &apply(F &&f, BitVector &Out, BitVector const &Arg,
                           ArgTys const &...Args) {
-    assert(llvm::all_of(
-               std::initializer_list<unsigned>{Args.size()...},
-               [&Arg](auto const &BV) { return Arg.size() == BV; }) &&
-           "consistent sizes");
+    assert(((Arg.size() == Args.size()) && ...) && "consistent sizes");
     Out.resize(Arg.size());
     for (size_type I = 0, E = Arg.Bits.size(); I != E; ++I)
       Out.Bits[I] = f(Arg.Bits[I], Args.Bits[I]...);

@kazutakahirata kazutakahirata merged commit b436488 into llvm:main Oct 2, 2025
13 of 14 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_20251001_ADT_BitVector_fold_expr branch October 2, 2025 16:28
mahesh-attarde pushed a commit to mahesh-attarde/llvm-project that referenced this pull request Oct 3, 2025
This patch simplifies the assertion by replacing the std::all_of check
with a more direct C++17 fold expression.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants