Talk:cpp/algorithm/is sorted

1 1 3 4 5 is not an ascending order, it's a non-descending order. The wording in the standard is correct, your wording is not. The fact that is_sorted returns true for this example is proof of that.
 * ok, I changed ascending to non-descending for you --Cubbi (talk) 08:48, 16 March 2016 (PDT)

Why is n non-negative
In "a sequence is sorted with respect to a comparator comp if for any iterator it pointing to the sequence and any non-negative integer n such that it + n is a valid iterator pointing to an element of the sequence, comp(*(it + n), *it) evaluates to false," if n=0, and comp is std::less_equal<>, wouldn't comp(*(it + 0), *it) be true, so is_sorted will always return false? Should n be a positive integer instead?


 * std isn't a valid comparator as it doesn't establish a strict weak ordering (required by the requirement). Note that even if  was defined to be a strictly positive integer, it would still be the case that  would evaluate to  if . --Ybab321 (talk) 07:56, 27 September 2020 (PDT)