Add operator- to Path's reverse_iterator. Needed for D19666
authorFilipe Cabecinhas <me@filcab.net>
Fri, 29 Apr 2016 16:48:07 +0000 (16:48 +0000)
committerFilipe Cabecinhas <me@filcab.net>
Fri, 29 Apr 2016 16:48:07 +0000 (16:48 +0000)
Reviewers: rafael, craig.topper, bogner

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D19724

llvm-svn: 268062

llvm/include/llvm/Support/Path.h
llvm/lib/Support/Path.cpp

index 5b9f50e..f803103 100644 (file)
@@ -87,6 +87,9 @@ public:
   reverse_iterator &operator++();    // preincrement
   bool operator==(const reverse_iterator &RHS) const;
   bool operator!=(const reverse_iterator &RHS) const { return !(*this == RHS); }
+
+  /// @brief Difference in bytes between this and RHS.
+  ptrdiff_t operator-(const reverse_iterator &RHS) const;
 };
 
 /// @brief Get begin iterator over \a path.
index 875bf75..f9a71b9 100644 (file)
@@ -353,6 +353,10 @@ bool reverse_iterator::operator==(const reverse_iterator &RHS) const {
          Position == RHS.Position;
 }
 
+ptrdiff_t reverse_iterator::operator-(const reverse_iterator &RHS) const {
+  return Position - RHS.Position;
+}
+
 StringRef root_path(StringRef path) {
   const_iterator b = begin(path),
                  pos = b,