25 Algorithms library [algorithms]

25.4 Sorting and related operations [alg.sorting]

25.4.1 Sorting [alg.sort]

25.4.1.5 is_sorted [is.sorted]

template<class ForwardIterator> bool is_sorted(ForwardIterator first, ForwardIterator last);

Returns: is_sorted_until(first, last) == last

template<class ForwardIterator, class Compare> bool is_sorted(ForwardIterator first, ForwardIterator last, Compare comp);

Returns: is_sorted_until(first, last, comp) == last

template<class ForwardIterator> ForwardIterator is_sorted_until(ForwardIterator first, ForwardIterator last); template<class ForwardIterator, class Compare> ForwardIterator is_sorted_until(ForwardIterator first, ForwardIterator last, Compare comp);

Returns: If distance(first, last) < 2, returns last. Otherwise, returns the last iterator i in [first,last] for which the range [first,i) is sorted.

Complexity: Linear.