My own reasoning for it is that there is no random access and there is no way to know the bounds. But then why do we have std::advance? [EDIT] And come to think of it, why is there no std::deadvance (for lack of a better word)?
My own reasoning for it is that there is no random access and there
Share
You are right; the requirements for
operator+/-is that it be anO(1)operation, which cannot be met by bidirectional iterators.std::advancehas no such speed requirement (but will use it when available, e.g., for random access iterators).Note that boost has
boost::nextandboost::priorimplementations for iterators; I’m not sure what their status is on standardization but if it’s in boost it’s solid.