[PATCH] D45792: [ADT] Teach reverse() about filter_iterator ranges

Vedant Kumar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 20 15:10:49 PDT 2018


vsk abandoned this revision.
vsk added a comment.

In https://reviews.llvm.org/D45792#1072947, @vsk wrote:

> In https://reviews.llvm.org/D45792#1072601, @timshen wrote:
>
> > My understanding is that, the reason why reverse_iterator<filter_iterator<I, F>> doesn't "just work" is because filter_iterator<I> is only a forward_iterator, while reverse_iterator expects a bidirectional_iterator. Can we make filter_iterator bidirectional instead?
>
>
> I think it's possible. I've sketched a version of this which passes tests: https://reviews.llvm.org/D45853. I haven't got all of the enable_ifs finalized, but it should be simpler than this patch.
>
> The downside is that it introduces copies of the wrapped begin/end iterators, as well as the predicate functor. That's why I'm leaning towards adding an overload of reverse(), but I'm open to either approach.


I've realized that the current version of filter_iterator doesn't support predicates which capture move-only types, so I no longer have reservations about just making filter_iterator bidirectional.

I'll abandon this in favor of https://reviews.llvm.org/D45853.


https://reviews.llvm.org/D45792





More information about the llvm-commits mailing list