[llvm] 388b8c1 - [ADT] Use fold expressions to compare tuples. NFCI

Benjamin Kramer via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 24 16:42:32 PST 2023


Author: Benjamin Kramer
Date: 2023-01-25T01:42:17+01:00
New Revision: 388b8c16c5610a54c639bb74e3c8de161e8ca1c6

URL: https://github.com/llvm/llvm-project/commit/388b8c16c5610a54c639bb74e3c8de161e8ca1c6
DIFF: https://github.com/llvm/llvm-project/commit/388b8c16c5610a54c639bb74e3c8de161e8ca1c6.diff

LOG: [ADT] Use fold expressions to compare tuples. NFCI

Added: 
    

Modified: 
    llvm/include/llvm/ADT/STLExtras.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/ADT/STLExtras.h b/llvm/include/llvm/ADT/STLExtras.h
index f6a1bd89bbe8..79b145632d5a 100644
--- a/llvm/include/llvm/ADT/STLExtras.h
+++ b/llvm/include/llvm/ADT/STLExtras.h
@@ -26,7 +26,6 @@
 #include "llvm/Config/abi-breaking.h"
 #include "llvm/Support/ErrorHandling.h"
 #include <algorithm>
-#include <array>
 #include <cassert>
 #include <cstddef>
 #include <cstdint>
@@ -787,9 +786,8 @@ struct zip_common : public zip_traits<ZipType, Iters...> {
   template <size_t... Ns>
   bool test_all_equals(const zip_common &other,
             std::index_sequence<Ns...>) const {
-    return all_of(std::initializer_list<bool>{std::get<Ns>(this->iterators) ==
-                                              std::get<Ns>(other.iterators)...},
-                  identity<bool>{});
+    return ((std::get<Ns>(this->iterators) == std::get<Ns>(other.iterators)) &&
+            ...);
   }
 
 public:
@@ -833,10 +831,8 @@ class zip_shortest : public zip_common<zip_shortest<Iters...>, Iters...> {
   template <size_t... Ns>
   bool test(const zip_shortest<Iters...> &other,
             std::index_sequence<Ns...>) const {
-    return all_of(
-        std::array<bool, sizeof...(Ns)>({std::get<Ns>(this->iterators) !=
-                                         std::get<Ns>(other.iterators)...}),
-        identity<bool>{});
+    return ((std::get<Ns>(this->iterators) != std::get<Ns>(other.iterators)) &&
+            ...);
   }
 
 public:
@@ -966,10 +962,8 @@ class zip_longest_iterator
   template <size_t... Ns>
   bool test(const zip_longest_iterator<Iters...> &other,
             std::index_sequence<Ns...>) const {
-    return llvm::any_of(
-        std::initializer_list<bool>{std::get<Ns>(this->iterators) !=
-                                    std::get<Ns>(other.iterators)...},
-        identity<bool>{});
+    return ((std::get<Ns>(this->iterators) != std::get<Ns>(other.iterators)) ||
+            ...);
   }
 
   template <size_t... Ns> value_type deref(std::index_sequence<Ns...>) const {


        


More information about the llvm-commits mailing list