[Object][ELF] ELFEntityIterator : Add operators for random access
authorShankar Easwaran <shankare@codeaurora.org>
Tue, 17 Mar 2015 02:12:35 +0000 (02:12 +0000)
committerShankar Easwaran <shankare@codeaurora.org>
Tue, 17 Mar 2015 02:12:35 +0000 (02:12 +0000)
Add operators add/subtract for random access. This is essentially used by
lld.

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

include/llvm/Object/ELF.h

index 8a5105f5a4bdfa3ab04abda9b80202e1f6b1dc11..0202e06990560c9cd7d4456fb51970132300d3ae 100644 (file)
@@ -94,6 +94,18 @@ public:
       return *this;
     }
 
+    ELFEntityIterator &operator+(difference_type n) {
+      assert(Current && "Attempted to increment an invalid iterator!");
+      Current += n;
+      return *this;
+    }
+
+    ELFEntityIterator &operator-(difference_type n) {
+      assert(Current && "Attempted to subtract an invalid iterator!");
+      Current -= n;
+      return *this;
+    }
+
     ELFEntityIterator operator ++(int) {
       ELFEntityIterator Tmp = *this;
       ++*this;