I have a custom iterator class conforming to the bidirectional iterator requirements (but not random access). However, the distance of two iterators can also be found in constant time. Conceptually, it2 - it1
is efficient, but it += n
is not (neither of these operator overloads is actually implemented).
Is it reasonable to overload std::distance()
to allow standard library algorithms to compute distances efficiently with this iterator?
I found conflicting information about the appropriateness of tampering with std
namespace things.