[llvm] r244620 - Add non-member begin and end so that drop_begin works on iterator_range.

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 11 10:21:38 PDT 2015


On Tue, Aug 11, 2015 at 9:12 AM, Rafael Espindola via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> Author: rafael
> Date: Tue Aug 11 11:12:56 2015
> New Revision: 244620
>
> URL: http://llvm.org/viewvc/llvm-project?rev=244620&view=rev
> Log:
> Add non-member begin and end so that drop_begin works on iterator_range.
>

It might be that drop_begin needs to be changed instead?

I asked Richard but I don't think he saw the email, we might want something
like:

... adl_begin(x) {
  using std::begin;
  return begin(x);
}

& that should work with iterator_range (because std::begin should be
templated to do the obvious x.begin(), I think?)?


>
> 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=244620&r1=244619&r2=244620&view=diff
>
> ==============================================================================
> --- llvm/trunk/include/llvm/ADT/iterator_range.h (original)
> +++ llvm/trunk/include/llvm/ADT/iterator_range.h Tue Aug 11 11:12:56 2015
> @@ -47,6 +47,16 @@ public:
>    IteratorT end() const { return end_iterator; }
>  };
>
> +template <typename IteratorT>
> +IteratorT begin(const iterator_range<IteratorT> &R) {
> +  return R.begin();
> +}
> +
> +template <typename IteratorT>
> +IteratorT end(const iterator_range<IteratorT> &R) {
> +  return R.end();
> +}
> +
>  /// \brief Convenience function for iterating over sub-ranges.
>  ///
>  /// This provides a bit of syntactic sugar to make using sub-ranges
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150811/0be7ddcc/attachment.html>


More information about the llvm-commits mailing list