[PATCH] D17870: [ADT] Add an 'llvm::seq' function which produces an iterator range over a sequence of values. It increments through the values in the half-open range: [Begin, End), producing those values when indirecting the iterator. It should support integers...

Pete Cooper via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 3 14:49:52 PST 2016


Hi Chandler

Haven’t looked at the code yet, but I like the idea and the use of it you gave.

Seems like most integer cases are going to start at 0.  Could we have a seq(n) to handle [0, n) ranges?

Cheers,
Pete
> On Mar 3, 2016, at 2:47 PM, Chandler Carruth via llvm-commits <llvm-commits at lists.llvm.org> wrote:
> 
> chandlerc created this revision.
> chandlerc added reviewers: hfinkel, dexonsmith.
> chandlerc added a subscriber: llvm-commits.
> Herald added a subscriber: mcrosier.
> 
> ..., iterators, and any other type providing these basic arithmetic operations.
> 
> This came up in the C++ standards committee meeting, and it seemed like
> a useful construct that LLVM might want as well, and I wanted to
> understand how easily we could solve it. I suspect this can be used to
> write simpler counting loops even in LLVM along the lines of:
> 
>  for (int i : seq(0, v.size())) {
>    ...
>  };
> 
> As part of this, I had to fix the lack of a proxy object returned from
> the operator[] in our iterator facade.
> 
> http://reviews.llvm.org/D17870
> 
> Files:
>  include/llvm/ADT/Sequence.h
>  include/llvm/ADT/iterator.h
>  unittests/ADT/CMakeLists.txt
>  unittests/ADT/SequenceTest.cpp
> 
> <D17870.49779.patch>_______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits



More information about the llvm-commits mailing list