I am developing a small library for my work, and I derived a few classes from the standard random-access iterator category. This allows me to use things like iterator traits and to not worry too much when I use standard libraries like algorithm
for example. Of course I know I don't have to, and that I could either chose the bidirectional category instead or even implement my own. But that is not the point.
IMO, the "gap" between the bidirectional and random-access categories is too large, and I don't understand the necessity for the subtraction and comparison operators between iterators -- that is: a-b
, a<b
and a>b
(and the loose variants thereof).
Why does the standard force the implementation of these operators, and could someone please give me an example where the (in)equality test, mixed iterator-scalar artithmetic (compound or not) operators and the offset dereference operator are not sufficient?
-pedantic
, but the correct term in this case is category, not interface. Also that differences are the hole point about duck typying vs inheritance approach. – Porettstd::distance
of course. – JeroboamThe difference between two points (maths) is a point
is plain wrong – Feeble