[PATCH] D145332: [ADT] Clean up zip iterators. NFC.
Jakub Kuderski via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 6 08:17:26 PST 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe969c803818c: [ADT] Clean up zip iterators. NFC. (authored by kuhar).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D145332/new/
https://reviews.llvm.org/D145332
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
@@ -827,32 +827,28 @@
};
template <typename... Iters>
-struct zip_first : public zip_common<zip_first<Iters...>, Iters...> {
- using Base = zip_common<zip_first<Iters...>, Iters...>;
+struct zip_first : zip_common<zip_first<Iters...>, Iters...> {
+ using zip_common<zip_first, Iters...>::zip_common;
- bool operator==(const zip_first<Iters...> &other) const {
+ bool operator==(const zip_first &other) const {
return std::get<0>(this->iterators) == std::get<0>(other.iterators);
}
-
- zip_first(Iters &&... ts) : Base(std::forward<Iters>(ts)...) {}
};
template <typename... Iters>
-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 ((std::get<Ns>(this->iterators) != std::get<Ns>(other.iterators)) &&
- ...);
- }
-
-public:
- using Base = zip_common<zip_shortest<Iters...>, Iters...>;
+struct zip_shortest : zip_common<zip_shortest<Iters...>, Iters...> {
+ using zip_common<zip_shortest, Iters...>::zip_common;
- zip_shortest(Iters &&... ts) : Base(std::forward<Iters>(ts)...) {}
+ bool operator==(const zip_shortest &other) const {
+ return any_iterator_equals(other, std::index_sequence_for<Iters...>{});
+ }
- bool operator==(const zip_shortest<Iters...> &other) const {
- return !test(other, std::index_sequence_for<Iters...>{});
+private:
+ template <size_t... Ns>
+ bool any_iterator_equals(const zip_shortest &other,
+ std::index_sequence<Ns...>) const {
+ return ((std::get<Ns>(this->iterators) == std::get<Ns>(other.iterators)) ||
+ ...);
}
};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D145332.502664.patch
Type: text/x-patch
Size: 1900 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230306/c4d86af5/attachment.bin>
More information about the llvm-commits
mailing list