
auto i = is_sorted_until(f, l, r) assert(is_sorted(f, i));
I wondered about this when I looked at the docs and was going to suggest "the docs should be explicit about which iterator they return"; then I decided that there was (obviously!) only one thing that could sensibly be returned. I.e. if the input is 1,2,3,4,5,0,42,12 then the result should be an iterator referring to the 0 element. Surely this what it does, no?
I'm almost 100% certain it does this, but I'm not looking at the standard right now. If it turns out that it doesn't do this then I would say that it's a specification error.
return adjacent_find(f, l, not2(pred));
Right, except that that returns the "wrong" iterator of the pair, i.e. it would return an iterator returning to the 5 in the example above. You can fix that by incrementing the iterator, but that has to consider the end case specially.
Ah. I see it now. I forgot which iterator adjacent_find returns. So: auto i = adjacent_find(f, l, not2(pred)); return i == l ? l : next(i);