https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122224

--- Comment #5 from M Welinder <terra at gnome dot org> ---
> std::prev(it, n) is equivalent to std::advance(it, -n)

Is integer overflow for the negation an issue?

There doesn't seem to be much help in the standard, although
https://en.cppreference.com/w/cpp/named_req/RandomAccessIterator.html (for "r
-= n") shows that at some point this was considered in that context.

Aside: much of the iterator part of the standard feels a bit like a work in
progress.  E.g., someone forgot to require that the Distance argument for
std::advance should be integral.  Or even arithmetic.

Reply via email to