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

Zachary Turner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 6 14:11:48 PST 2017


zturner created this revision.
zturner added a reviewer: chandlerc.
zturner added a subscriber: llvm-commits.

https://reviews.llvm.org/D28413

Files:
  llvm/include/llvm/ADT/iterator.h


Index: llvm/include/llvm/ADT/iterator.h
===================================================================
--- llvm/include/llvm/ADT/iterator.h
+++ llvm/include/llvm/ADT/iterator.h
@@ -33,6 +33,26 @@
 /// Another abstraction that this doesn't provide is implementing increment in
 /// terms of addition of one. These aren't equivalent for all iterator
 /// categories, and respecting that adds a lot of complexity for little gain.
+///
+/// Classes wishing to use `iterator_facade_base` should implement the following
+/// methods:
+///
+/// Forward Iterators:
+///   DerivedT &operator=(const DerivedT &R);
+///   bool operator==(const DerivedT &R) const;
+///   const T &operator*() const;
+///   T &operator*();
+///   DerivedT &operator+=(DifferenceTypeT N);
+///
+/// Bidirectional Iterators:
+///   (All methods of forward iterators, plus the following)
+///   DerivedT &operator-=(DifferenceTypeT N);
+///
+/// Random-access Iterators:
+///   (All methods of bidirectional iterators, plus the following)
+///   bool operator<(const DerivedT &RHS) const;
+///   DifferenceTypeT operator-(const DerivedT &R) const;
+///
 template <typename DerivedT, typename IteratorCategoryT, typename T,
           typename DifferenceTypeT = std::ptrdiff_t, typename PointerT = T *,
           typename ReferenceT = T &>


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28413.83424.patch
Type: text/x-patch
Size: 1313 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170106/497637d6/attachment.bin>


More information about the llvm-commits mailing list