[PATCH] D136777: llvm::zip should not require assignment operator
Tomás Longeri via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 26 12:00:47 PDT 2022
tlongeri created this revision.
tlongeri added a reviewer: mehdi_amini.
Herald added a project: All.
tlongeri requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D136777
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
@@ -646,13 +646,13 @@
}
template <size_t... Ns>
- decltype(iterators) tup_inc(std::index_sequence<Ns...>) const {
- return std::tuple<Iters...>(std::next(std::get<Ns>(iterators))...);
+ void tup_inc(std::index_sequence<Ns...>) {
+ (++std::get<Ns>(iterators), ...);
}
template <size_t... Ns>
- decltype(iterators) tup_dec(std::index_sequence<Ns...>) const {
- return std::tuple<Iters...>(std::prev(std::get<Ns>(iterators))...);
+ void tup_dec(std::index_sequence<Ns...>) {
+ (--std::get<Ns>(iterators), ...);
}
template <size_t... Ns>
@@ -671,14 +671,14 @@
}
ZipType &operator++() {
- iterators = tup_inc(std::index_sequence_for<Iters...>{});
+ tup_inc(std::index_sequence_for<Iters...>{});
return *reinterpret_cast<ZipType *>(this);
}
ZipType &operator--() {
static_assert(Base::IsBidirectional,
"All inner iterators must be at least bidirectional.");
- iterators = tup_dec(std::index_sequence_for<Iters...>{});
+ tup_dec(std::index_sequence_for<Iters...>{});
return *reinterpret_cast<ZipType *>(this);
}
@@ -769,10 +769,9 @@
namespace detail {
template <typename Iter>
-Iter next_or_end(const Iter &I, const Iter &End) {
- if (I == End)
- return End;
- return std::next(I);
+void increment_or_end(Iter &I, const Iter &End) {
+ if (I != End)
+ ++I;
}
template <typename Iter>
@@ -826,9 +825,8 @@
}
template <size_t... Ns>
- decltype(iterators) tup_inc(std::index_sequence<Ns...>) const {
- return std::tuple<Iters...>(
- next_or_end(std::get<Ns>(iterators), std::get<Ns>(end_iterators))...);
+ void tup_inc(std::index_sequence<Ns...>) const {
+ (increment_or_end(std::get<Ns>(iterators), std::get<Ns>(end_iterators)), ...);
}
public:
@@ -841,7 +839,7 @@
}
zip_longest_iterator<Iters...> &operator++() {
- iterators = tup_inc(std::index_sequence_for<Iters...>{});
+ tup_inc(std::index_sequence_for<Iters...>{});
return *this;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136777.470894.patch
Type: text/x-patch
Size: 2189 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221026/e0865abc/attachment.bin>
More information about the llvm-commits
mailing list