[llvm] r207257 - SCC: Provide operator->() through iterator_facade_base
Duncan P. N. Exon Smith
dexonsmith at apple.com
Fri Apr 25 11:43:42 PDT 2014
Author: dexonsmith
Date: Fri Apr 25 13:43:41 2014
New Revision: 207257
URL: http://llvm.org/viewvc/llvm-project?rev=207257&view=rev
Log:
SCC: Provide operator->() through iterator_facade_base
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>
Modified:
llvm/trunk/include/llvm/ADT/SCCIterator.h
Modified: llvm/trunk/include/llvm/ADT/SCCIterator.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/SCCIterator.h?rev=207257&r1=207256&r2=207257&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/SCCIterator.h (original)
+++ llvm/trunk/include/llvm/ADT/SCCIterator.h Fri Apr 25 13:43:41 2014
@@ -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!");
More information about the llvm-commits
mailing list