util/DereferenceIterator, TerminatedArray: added operator-(const IteratorType&) to DereferenceIterator and TerminatedArray::iterator

It is required by std::distance and some std algos.
This commit is contained in:
gd 2025-01-29 15:52:19 +02:00
parent ab011adf77
commit 93bf99f639
2 changed files with 8 additions and 0 deletions

@ -82,6 +82,10 @@ public:
return DereferenceIterator{original - n};
}
constexpr auto operator-(const DereferenceIterator<IT, VT>& other) const noexcept {
return std::distance(other.original, original);
}
/* this is a template to allow comparisons with sentinel end
iterators */
template<typename IT2>

@ -101,6 +101,10 @@ public:
return iterator{cursor - n};
}
constexpr auto operator-(const iterator& other) const noexcept {
return std::distance(other.cursor, cursor);
}
reference operator*() const noexcept {
return *cursor;
}