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

Vedant Kumar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 19 18:05:39 PDT 2018


vsk added a comment.

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.


https://reviews.llvm.org/D45792





More information about the llvm-commits mailing list