[cfe-dev] C++11 reverse iterators (was C++11 is here)

Chris Lattner sabre at nondot.org
Tue Mar 4 16:30:46 PST 2014


On Mar 4, 2014, at 3:38 PM, Sean Silva <silvas at purdue.edu> wrote:
>> I'm not aware of the prior art or standards are here, but I think that a global reverse() adapter is the way to go.  Likewise, we should have a standard "enumerate()" adaptor like python.
>> 
>> `enumerate` is going to be so much more annoying to use without tuple unpacking in the `for` syntax :(
> 
> Sure, it won't be as nice as Python, but in my limited experience with C++'11 foreach loops, the #1 reason I can't use them is because there is no way to parallel iterate two vectors (as a random example) which would be simple if an index were available.  It doesn't matter to me how syntactically convenient it is to get the index, so long as it is possible.
> 
>  Iterating two vectors in parallel also suggests a variadic `auto zip(...) -> std::tuple<...>` helper.

Right, but that is simply *one* example where enumerate would be useful.  There are lots of other ones.

-Chris

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140304/4986bc53/attachment.html>


More information about the cfe-dev mailing list