[PATCH] D145025: [ADT] Clean up `enumerate` implementation. NFC.
Jakub Kuderski via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 28 19:55:47 PST 2023
kuhar created this revision.
kuhar added reviewers: dblaikie, zero9178, Mogball, antiagainst, kazu, beanz, zturner, mehdi_amini.
Herald added a subscriber: hanchung.
Herald added a project: All.
kuhar requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
- Remove unnecessary member functions.
- Fix code sample.
This is in preparation for landing future changes in https://reviews.llvm.org/D144503.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D145025
Files:
llvm/include/llvm/ADT/STLExtras.h
Index: llvm/include/llvm/ADT/STLExtras.h
===================================================================
--- llvm/include/llvm/ADT/STLExtras.h
+++ llvm/include/llvm/ADT/STLExtras.h
@@ -2197,18 +2197,9 @@
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 @@
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;
};
@@ -2296,13 +2281,13 @@
///
/// 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:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D145025.501364.patch
Type: text/x-patch
Size: 1451 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230301/4abd1359/attachment.bin>
More information about the llvm-commits
mailing list