[llvm-dev] Openness to a "zip_iterator" type?
Mehdi Amini via llvm-dev
llvm-dev at lists.llvm.org
Wed Dec 14 09:41:00 PST 2016
> On Dec 14, 2016, at 9:37 AM, Keane, Erich via llvm-dev <llvm-dev at lists.llvm.org> wrote:
>
> One of my coworkers noticed that we(Clang/LLVM) have quite a few places where we need to iterate through 2 equally sized ranges at the same time, often related to parm/arg relationships. In a few cases we(Clang/LLVM) use a traditional for-loop with 2 iterators in it. In a few others, the implementation uses range-for over 1 range with an iterator pattern on the other.
>
> IMO, the correct solution to this would be a templated 'zip' type (similar, though not identical to http://www.boost.org/doc/libs/1_62_0/libs/iterator/doc/zip_iterator.html) that would permit:
>
> for (auto&& things : IteratorZip(ParmRange, ArgRange)) {
> [CurParm, CurArg] = things; // things is a tuple that contains a reference to each value
> }
>
>
> If I were to implement this IteratorZip type for the LLVM codebase, would this be something the community would be interested in/accept/use? Am I missing an obvious existing implementation somewhere?
Yes: include/llvm/ADT/STLExtras.h has zip.
See also unittests/ADT/IteratorTest.cpp.
—
Mehdi
More information about the llvm-dev
mailing list