<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Sun, Mar 6, 2016 at 11:45 PM Justin Bogner <<a href="mailto:mail@justinbogner.com">mail@justinbogner.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Chandler Carruth via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>> writes:<br>
> This came up in the C++ standards committee meeting, and it seemed like<br>
> a useful construct that LLVM might want as well, and I wanted to<br>
> understand how easily we could solve it. I suspect this can be used to<br>
> write simpler counting loops even in LLVM along the lines of:<br>
><br>
>   for (int i : seq(0, v.size())) {<br>
>     ...<br>
>   };<br>
<br>
I don't get how this gains us anything. this adds a bunch of code to<br>
save, well, three characters over a regular loop:<br>
<br>
    for (int i = 0; i < v.size(); ++i) {<br>
      ...<br>
    }<br></blockquote><div><br></div><div>Well it avoids the common mistake made here. ;] The correct comparison would be:</div><div><br></div><div>  for (int i = 0, Size = v.size(); i < Size; ++i) {</div><div>    ...</div><div>  }</div><div><br></div><div>Which is a decent bit longer and requires us to come up with a name for Size. Sometimes, that's really nice, but sometimes its a pain.</div><div><br></div><div>I'm still actually torn on whether this is a useful idiom. But others seemed to think it was in committee, and I was curious what folks in LLVM land think, so figured I'd write it up and see. So hopefully we'll get a few more comments before moving forward.</div><div><br></div><div>-Chandler</div></div></div>