[LLVMdev] C++11 reverse iterators (was C++11 is here)

Pete Cooper peter_cooper at apple.com
Sun Mar 2 20:13:41 PST 2014



Sent from my iPhone

> On Mar 1, 2014, at 2:06 PM, Renato Golin <renato.golin at linaro.org> wrote:
> 
>> On 1 March 2014 19:24, David Chisnall <David.Chisnall at cl.cam.ac.uk> wrote:
>> for (auto V : X.foo()) {
>>        ...
>> }
It would also be good to agree on a way to handle reverse iterators, especially on those which already use begin() and end() for going forwards.  For example

For (auto& bb : MF)

Will iterate the BBs in a machine function forwards. How should we do it backwards? Whatever we choose should be the standard across other similar classes of this in different parts of the code base. I have 3 potential answers which are all quite similar.

1: for (auto& bb : MF.reverse())
2: for (auto& bb : MF.r_bb())
3: for (auto& bb : reverse(MF))

Personally I like 1 but I'm open to suggestions. Arguably 3 could also use 1 is people liked both. 2 is more explicit about what's going on but I don't like the style too much.

Pete
> 
> +1
> 
> --renato
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev



More information about the llvm-dev mailing list