[llvm] r203060 - Change the tag on this iterator to bidir and implement enough operators to make it true.

Owen Anderson resistor at mac.com
Wed Mar 5 18:02:43 PST 2014


Author: resistor
Date: Wed Mar  5 20:02:43 2014
New Revision: 203060

URL: http://llvm.org/viewvc/llvm-project?rev=203060&view=rev
Log:
Change the tag on this iterator to bidir and implement enough operators to make it true.
It ought to be possible to make this truly random access if anyone cares enough.

Modified:
    llvm/trunk/include/llvm/IR/Metadata.h

Modified: llvm/trunk/include/llvm/IR/Metadata.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Metadata.h?rev=203060&r1=203059&r2=203060&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Metadata.h (original)
+++ llvm/trunk/include/llvm/IR/Metadata.h Wed Mar  5 20:02:43 2014
@@ -210,7 +210,7 @@ class NamedMDNode : public ilist_node<Na
 
   template<class T1, class T2>
   class op_iterator_impl :
-      public std::iterator<std::random_access_iterator_tag, T2> {
+      public std::iterator<std::bidirectional_iterator_tag, T2> {
     const NamedMDNode *Node;
     unsigned Idx;
     op_iterator_impl(const NamedMDNode *N, unsigned i) : Node(N), Idx(i) { }
@@ -232,6 +232,16 @@ class NamedMDNode : public ilist_node<Na
       operator++();
       return tmp;
     }
+    op_iterator_impl &operator--() {
+      --Idx;
+      return *this;
+    }
+    op_iterator_impl operator--(int) {
+      op_iterator_impl tmp(*this);
+      operator--();
+      return tmp;
+    }
+
     op_iterator_impl &operator=(const op_iterator_impl &o) {
       Node = o.Node;
       Idx = o.Idx;





More information about the llvm-commits mailing list