<div dir="ltr"><div>Hi Chandler,</div><div><br></div><div>Agreed - ranges aren't containers, just views of sequences. Still, that's all many algorithms want, and it's just as valid to ask whether a sequence is empty as it is to ask that of a container.</div>
<div><br></div><div>No contest on points 2 or 3, but I'm confused about point 4. When are ranges not pairs of iterators? I mean in a way that would clash with the proposal for empty() to be defined as '(begin(r) == end(r)' ?</div>
<div><br></div><div>The benefit of doing this is similar in kind, though obviously less significant, to the benefit of range based for loops. It doesn't enable anything fundamentally new, but improving readability of C++ code is welcome.</div>
<div><br></div><div>This is easy to punt (and I won't be especially bothered if that's what we do), but it also seems like it would be easy to implement our own version (llvm::is_empty?) and replace it when the committee decides on something, the same way we did with llvm::move? Is there any reason not to follow that approach?</div>
<div><br></div><div>Cheers,</div><div>Lang.</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Mar 20, 2014 at 2:31 PM, Chandler Carruth <span dir="ltr"><<a href="mailto:chandlerc@google.com" target="_blank">chandlerc@google.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra">Since Richard first poked me about this, I'm still debating this.</div><div class="gmail_extra">
<br></div><div class="gmail_extra">I'm torn in a bunch of different ways:</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">1) iterator_range is *not* a container. It shouldn't and can't be used like one.</div><div class="gmail_extra">2) members are really hard to extend. they make templates harder not easier because the widen the set of interfaces which *must* be on a given container</div>

<div class="gmail_extra">3) the concept of testing for emptiness is actually inherently useful for all ranges, unlike many other proposed extensions to the member interface, so maybe its OK to grow the interface in this direction</div>

<div class="gmail_extra">4) basing emptiness on iterators seems really bad because one of the important utilities of ranges is that they may expose concepts which are more flexible and efficient than a pair of iterators</div>

<div class="gmail_extra"><br></div><div class="gmail_extra">However, one thing makes me inclined to say "no" to this: the benefit is miniscule. It is too simple to just compare the iterators and not cross any of these bridges today.</div>

<div class="gmail_extra"><div class=""><br><div class="gmail_quote">On Wed, Mar 19, 2014 at 11:57 AM, Duncan P. N. Exon Smith <span dir="ltr"><<a href="mailto:dexonsmith@apple.com" target="_blank">dexonsmith@apple.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="overflow:hidden"><div>> This is a pattern I ran into a handful of times when range-ifying<br>

> parts of clang (but not so frequently that I felt it was a major win),<br>
> so I'm roughly in favor of the API. However, if there's been<br>
> standardization efforts for range, we should be sure that we're doing<br>
> something compatible there.<br>
<br>
</div>There are a couple of proposals [1][2] that I can find.  It sounds like the<br>
exact set of methods to provide is somewhat contentious [3].  empty() seems<br>
pretty innocuous though.  Note that the standard proposals use std::range<br>
instead of std::iterator_range.<br>
<br>
In my opinion, other methods (e.g., front(), back(), and (for random access<br>
iterators) operator[]) would also be useful.</div></blockquote></div><br></div>I think front, back, and [] are extremely contentious. =] While empty may be the most innocuous, it also seems the least useful today.</div></div>

<br>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
<br></blockquote></div><br></div>