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:
@ -82,6 +82,10 @@ public:
|
|||||||
return DereferenceIterator{original - n};
|
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
|
/* this is a template to allow comparisons with sentinel end
|
||||||
iterators */
|
iterators */
|
||||||
template<typename IT2>
|
template<typename IT2>
|
||||||
|
@ -101,6 +101,10 @@ public:
|
|||||||
return iterator{cursor - n};
|
return iterator{cursor - n};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constexpr auto operator-(const iterator& other) const noexcept {
|
||||||
|
return std::distance(other.cursor, cursor);
|
||||||
|
}
|
||||||
|
|
||||||
reference operator*() const noexcept {
|
reference operator*() const noexcept {
|
||||||
return *cursor;
|
return *cursor;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user