[PATCH] D45853: (WIP) Alternate approach to reversing filtered iterators

Tim Shen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 20 14:07:20 PDT 2018


timshen added inline comments.


================
Comment at: include/llvm/ADT/STLExtras.h:344
 
+  // TODO:
+  // typename std::enable_if<std::is_same<std::bidirectional_iterator_tag,
----------------
SFINAE wouldn't work here unless you make operator--() a function template, which is an overkill.

I suggest to specialize the class on bidirectional iterator. It might require some boilerplate. For example:
  template <typename Iter,
                    typename Predicate,
                    typename iter_tag = typename iterator_traits<Iter>::iterator_category>
  class filter_iterator_impl { ... };

  template <typename Iter, typename Predicate>
  class filter_iterator_impl<Iter, Predicate, std::bidrectional_iterator_tag> { ... };

  template <typename Iter, typename Predicate>
  using filter_iterator = filter_iterator_impl<Iter, Predicate>;  // to hide template parameter "iter_tag".


https://reviews.llvm.org/D45853





More information about the llvm-commits mailing list