[PATCH] D144834: [ADT] Fix const-correctness issues in `zippy`
Jakub Kuderski via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 27 17:52:07 PST 2023
kuhar added inline comments.
================
Comment at: llvm/unittests/ADT/IteratorTest.cpp:501-502
+ unsigned iters = 0;
+ for (auto [a, b, c] : zip_equal(SmallVector<int>{1, 2, 3}, std::string("abc"),
+ std::vector<bool>{true, false, true})) {
+ a = 3;
----------------
dblaikie wrote:
> Does this code work? How? Wouldn't the lifetimes of the temporary ranges expire before the body of the loop runs?
These ranges get moved into the `tuple<...> storage;` inside `zippy`. From then on, we can use references obtained from this `storage` to access them. So this should not rely on any lifetime extensions on the temporaries passed to `zip_equal`.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D144834/new/
https://reviews.llvm.org/D144834
More information about the llvm-commits
mailing list