Udostępnij za pośrednictwem


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
    );

Parameters

  • _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<.

Property Value/Return Value

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

Remarks

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.

Requirements

Header: <algorithm>

Namespace: std

See Also

Reference

is_sorted_until

<algorithm>

Standard Template Library

Other Resources

<algorithm> Members