[PATCH] D23703: [ADT] Add pointer_iterator, the opposite of pointee_iterator

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 19 10:32:20 PDT 2016


dblaikie added inline comments.

================
Comment at: include/llvm/ADT/iterator.h:269
@@ +268,3 @@
+
+  T operator*() const { return &*this->I; }
+};
----------------
This would make a non-conforming iterator (perhaps we should have a static_assert for this in iterator_adapter_base, if possible) - because you should be able to take references and pointers to op* and get the same thing back the next time you call op*, etc.

So, at least in theory/to be conforming, the iterator would need a pointer member that it initializes in op* (or op++/ctor) and returns a reference to that.

What do you think? Do we already have enough non-conforming iterators that this technicality isn't worth worrying about? Or is the extra contortion worthwhile? Is there a nice way to do it? (I suppose you have to do it in op*, because you don't know if the iterator is valid any other time so you can't pre-emptively initialize the pointer member)


https://reviews.llvm.org/D23703





More information about the llvm-commits mailing list