[llvm] f254acf - [ADT] Clean up `enumerate` implementation. NFC.

Jakub Kuderski via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 2 13:45:09 PST 2023


Author: Jakub Kuderski
Date: 2023-03-02T16:44:52-05:00
New Revision: f254acf571a72f1825a4dde8e9cd80d6ffc820eb

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

LOG: [ADT] Clean up `enumerate` implementation. NFC.

*  Remove unnecessary member functions.
*  Fix code sample.

This is in preparation for landing future changes in https://reviews.llvm.org/D144503.

Reviewed By: zero9178

Differential Revision: https://reviews.llvm.org/D145025

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 cc437681ec62c..0ee260bc99f23 100644
--- a/llvm/include/llvm/ADT/STLExtras.h
+++ b/llvm/include/llvm/ADT/STLExtras.h
@@ -2197,18 +2197,9 @@ template <typename R> struct result_pair {
 
   friend class enumerator_iter<R>;
 
-  result_pair() = default;
   result_pair(std::size_t Index, IterOfRange<R> Iter)
       : Index(Index), Iter(Iter) {}
 
-  result_pair(const result_pair<R> &Other)
-      : Index(Other.Index), Iter(Other.Iter) {}
-  result_pair &operator=(const result_pair &Other) {
-    Index = Other.Index;
-    Iter = Other.Iter;
-    return *this;
-  }
-
   std::size_t index() const { return Index; }
   value_reference value() const { return *Iter; }
 
@@ -2256,12 +2247,6 @@ class enumerator_iter
     return Result.Iter == RHS.Result.Iter;
   }
 
-  enumerator_iter(const enumerator_iter &Other) : Result(Other.Result) {}
-  enumerator_iter &operator=(const enumerator_iter &Other) {
-    Result = Other.Result;
-    return *this;
-  }
-
 private:
   result_type Result;
 };
@@ -2294,13 +2279,13 @@ template <typename R> class enumerator {
 ///
 /// std::vector<char> Items = {'A', 'B', 'C', 'D'};
 /// for (auto X : enumerate(Items)) {
-///   printf("Item %d - %c\n", X.index(), X.value());
+///   printf("Item %zu - %c\n", X.index(), X.value());
 /// }
 ///
 /// or using structured bindings:
 ///
 /// for (auto [Index, Value] : enumerate(Items)) {
-///   printf("Item %d - %c\n", Index, Value);
+///   printf("Item %zu - %c\n", Index, Value);
 /// }
 ///
 /// Output:


        


More information about the llvm-commits mailing list