Export (0) Print
Expand All

is_sorted

Returns true if the elements in the specified range are in sorted order.

template<class ForwardIterator>
    bool is_sorted(
        ForwardIterator _First, 
        ForwardIterator _Last
    );
template<class ForwardIterator, class BinaryPredicate>
    bool is_sorted(
        ForwardIterator _First, 
        ForwardIterator _Last, 
        BinaryPredicate _Comp
    );

_First

A forward iterator that indicates where the range to check begins.

_Last

A forward iterator that indicates the end of a range.

_Comp

The condition to test to determine an order between two elements. A predicate takes a single argument and returns true or false. This performs the same task as operator<.

Returns true if the elements within the specified range are in sorted order, false if they're not.

The first template function returns is_sorted_until(_First, _Last) == _Last. The operator< function performs the order comparison.

The second template function returns is_sorted_until(_First, _Last, _Comp) == _Last. The _Comp predicate function performs the order comparison.

Header: <algorithm>

Namespace: std

Show:
© 2014 Microsoft