SCC: Provide operator->() through iterator_facade_base
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Fri, 25 Apr 2014 18:43:41 +0000 (18:43 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Fri, 25 Apr 2014 18:43:41 +0000 (18:43 +0000)
Use the fancy new `iterator_facade_base` to add
`scc_iterator::operator->()`.  Remove other definitions where
`iterator_facade_base` does the right thing.

<rdar://problem/14292693>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207257 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ADT/SCCIterator.h

index 4732ef5..79f9ac4 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/GraphTraits.h"
+#include "llvm/ADT/iterator.h"
 #include <vector>
 
 namespace llvm {
@@ -36,18 +37,14 @@ namespace llvm {
 /// build up a vector of nodes in a particular SCC. Note that it is a forward
 /// iterator and thus you cannot backtrack or re-visit nodes.
 template <class GraphT, class GT = GraphTraits<GraphT>>
-class scc_iterator
-    : public std::iterator<std::forward_iterator_tag,
-                           const std::vector<typename GT::NodeType>,
-                           ptrdiff_t> {
+class scc_iterator : public iterator_facade_base<
+                         scc_iterator<GraphT, GT>, std::forward_iterator_tag,
+                         const std::vector<typename GT::NodeType>, ptrdiff_t> {
   typedef typename GT::NodeType NodeType;
   typedef typename GT::ChildIteratorType ChildItTy;
   typedef std::vector<NodeType *> SccTy;
-  typedef std::iterator<std::forward_iterator_tag,
-                        const std::vector<typename GT::NodeType>,
-                        ptrdiff_t> super;
-  typedef typename super::reference reference;
-  typedef typename super::pointer pointer;
+  typedef typename scc_iterator::reference reference;
+  typedef typename scc_iterator::pointer pointer;
 
   /// Element of VisitStack during DFS.
   struct StackElement {
@@ -115,17 +112,11 @@ public:
   bool operator==(const scc_iterator &x) const {
     return VisitStack == x.VisitStack && CurrentSCC == x.CurrentSCC;
   }
-  bool operator!=(const scc_iterator &x) const { return !operator==(x); }
 
   scc_iterator &operator++() {
     GetNextSCC();
     return *this;
   }
-  scc_iterator operator++(int) {
-    scc_iterator tmp = *this;
-    ++*this;
-    return tmp;
-  }
 
   const SccTy &operator*() const {
     assert(!CurrentSCC.empty() && "Dereferencing END SCC iterator!");