Index: llvm/include/llvm/ADT/iterator.h =================================================================== --- llvm/include/llvm/ADT/iterator.h +++ llvm/include/llvm/ADT/iterator.h @@ -86,6 +86,12 @@ tmp -= n; return tmp; } + DifferenceTypeT operator-(const DerivedT &i) const { + static_assert( + IsRandomAccess, + "The '-' operator is only defined for random access iterators."); + return i - *static_cast(this); + } DerivedT &operator++() { return static_cast(this)->operator+=(1); @@ -114,6 +120,13 @@ return !static_cast(this)->operator==(RHS); } + bool operator<(const DerivedT &RHS) const { + static_assert( + IsRandomAccess, + "Relational operators are only defined for random access iterators."); + return !static_cast(this)->operator>(RHS) && + !static_cast(this)->operator==(RHS); + } bool operator>(const DerivedT &RHS) const { static_assert( IsRandomAccess,