[llvm-dev] Openness to a "zip_iterator" type?

Keane, Erich via llvm-dev llvm-dev at lists.llvm.org
Wed Dec 14 09:37:11 PST 2016


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?

Thanks,
Erich


More information about the llvm-dev mailing list