[llvm] r205987 - iterator_range: Add an llvm::make_range() helper method.
Jim Grosbach
grosbach at apple.com
Thu Apr 10 15:52:39 PDT 2014
On Apr 10, 2014, at 3:10 PM, David Blaikie <dblaikie at gmail.com> wrote:
> On Thu, Apr 10, 2014 at 2:49 PM, Jim Grosbach <grosbach at apple.com> wrote:
>> Author: grosbach
>> Date: Thu Apr 10 16:49:22 2014
>> New Revision: 205987
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=205987&view=rev
>> Log:
>> iterator_range: Add an llvm::make_range() helper method.
>>
>> Convenience wrapper to make dealing with sub-ranges easier. Like the
>> iterator_range<> itself, if/when this sort of thing gets standards
>> blessing, it will be replaced by the official version.
>>
>> Modified:
>> llvm/trunk/include/llvm/ADT/iterator_range.h
>>
>> Modified: llvm/trunk/include/llvm/ADT/iterator_range.h
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/iterator_range.h?rev=205987&r1=205986&r2=205987&view=diff
>> ==============================================================================
>> --- llvm/trunk/include/llvm/ADT/iterator_range.h (original)
>> +++ llvm/trunk/include/llvm/ADT/iterator_range.h Thu Apr 10 16:49:22 2014
>> @@ -40,6 +40,14 @@ public:
>> IteratorT begin() const { return begin_iterator; }
>> IteratorT end() const { return end_iterator; }
>> };
>> +
>> +/// \brief Convenience function for iterating over sub-ranges.
>> +///
>> +/// This provides a bit of syntactic sugar to make using sub-ranges
>> +/// in for loops a bit easier. Analogous to std::make_pair().
>> +template<class T> iterator_range<T> make_range(const T &x, const T &y) {
>> + return (iterator_range<T>(x, y));
>
> The extra parens seem a bit... excessive?
Fair. No idea why I put those there.
> That was all I was going to say... but then I got bored/pedantic/something:
>
> You could pass x and y by value and use std::move inside, since
> iterator_range is going to take these things by value and do the same
> thing in its actor.
Sure, no real preference here. I just used const& per a quick water-cooler conversation w/ John. std::move() should give us the same optimization opportunities anywhere it matters, I think, though.
> So I did that in r205993.
Excellent, thanks!
>> +}
>> }
>>
>> #endif
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140410/5c2bf49b/attachment.html>
More information about the llvm-commits
mailing list