[PATCH] D28413: Add better documentation for iterator facade subclasses.

Chandler Carruth via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 6 15:23:39 PST 2017


chandlerc added inline comments.


================
Comment at: llvm/include/llvm/ADT/iterator.h:45-49
+///   DerivedT &operator+=(DifferenceTypeT N);
+///
+/// Bidirectional Iterators:
+///   (All methods of forward iterators, plus the following)
+///   DerivedT &operator-=(DifferenceTypeT N);
----------------
For both forward and bidirectional, you can instead implement (one overload of) operator++ and operator-- respectively. Generally, that's a better option for such iterators.

For random-access, you can skip implementing those because we can generate them from the += and -= (which we have to have you implement in order for random access to be fast).


https://reviews.llvm.org/D28413





More information about the llvm-commits mailing list