Details
- Reviewers
mehdi_amini dblaikie
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Add zip test. Fix tup_inc incorrectly remaining const. Rename increment_or_end to increment_if_not_end.
I've got mixed feelings - the mechanics of the change seem fine, but iterator requirements include copy assignability and copy constructibility - so whatever iterator you're going to use with this feature isn't implementing the iterator requirements and probably should be fixed? I guess the C++20 iterator concepts are a bit more flexible and may include this situation.
I've got mixed feelings - the mechanics of the change seem fine, but iterator requirements include copy assignability and copy constructibility - so whatever iterator you're going to use with this feature isn't implementing the iterator requirements and probably should be fixed?
It's a good point that we're supporting here iterators that aren't compliant with the general requirements. But I'm wondering if this isn't still a good thing?
That is: isn't it just good for ranges and all adaptors/filters/... to require the minimum amount of things they need from an iterator? (it's not like we're checking on every properties of an iterator everywhere just to force an arbitrary contract).
(we should also fix the iterator if possible, but I know also that some iterators are "fat" and avoiding copies may be valuable!)
I've got mixed feelings - the mechanics of the change seem fine, but iterator requirements include copy assignability and copy constructibility - so whatever iterator you're going to use with this feature isn't implementing the iterator requirements and probably should be fixed?
I missed this, to be honest. The context is just that I tried and failed to zip MLIR's ElementsAttrIterator, and I saw no reason why zip needed assignment.
I guess the C++20 iterator concepts are a bit more flexible and may include this situation.
Unfortunately, it looks like the C++20 input_or_output_iterator concept still requires move assignability (through -> weakly_incrementable -> movable)
Isn't it still a small improvement, though? Besides what Mehdi said, I would just add that it still seems like incrementing the iterators in-place is a bit better. Maybe I should adjust the description, though.
Edit: didn't see your reply
Yeah - though I think the existing code before your patch here requires copy constructibliity - so this patch does fix llvm::zip to work with these newer iterator concepts, which is good.
Isn't it still a small improvement, though? Besides what Mehdi said, I would just add that it still seems like incrementing the iterators in-place is a bit better. Maybe I should adjust the description, though.
Yep - might be worth checking the ElementsAttrIterator to ensure it at least meets the newer iterator concepts at least. (my usual concern here is not that changing one algorithm to be more lenient - but that a non-conforming iterator will run up against other problems, standard algorithms will have difficult/might have more stringent checks, etc).
On top of the patch here, we're also adding copy construction and copy assignment on ElementsAttrIterator by the way, it seems like reasonable addition and it seems like it was an oversight to not have it there (this particular iterator isn't that "fat": two bools and two pointers).