Export (0) Print
Expand All

minmax

Compares two input parameters and returns them as a pair, in order of lesser to greater.

template<class Type>
    pair<const Type&, const Type&>
        minmax(
            const Type& _Left, 
            const Type& _Right
        );
template<class Type, class BinaryPredicate>
    pair<const Type&, const Type&>
        minmax(
            const Type& _Left,
            const Type& _Right,
            BinaryPredicate _Comp
        );
template<class Type> 
    pair<Type&, Type&> 
        minmax(
            initializer_list<Type> _Ilist
        );
template<class Type, class BinaryPredicate> 
    pair<Type&, Type&> 
        minmax(
            initializer_list<Type> _Ilist, 
            BinaryPredicate _Comp
        );

_Left

The first of the two objects being compared.

_Right

The second of the two objects being compared.

_Comp

A binary predicate used to compare the two objects.

_IList

The initializer_list that contains the members to be compared.

Returns a pair of objects where the first is the lesser and the second is the greater. In the case of an initializer_list, the pair is the least object and the greatest object in the list.

The first template function returns pair<const Type&, const Type&>(_Right, _Left) if _Right is less than _Left. Otherwise, it returns pair<const Type&, const Type&>(_Left, _Right).

The second member function returns a pair where the first element is the lesser and the second is the greater when compared by the predicate _Comp.

The remaining template functions behave the same, except that they replace the _Left and _Right parameters with _IList.

The function performs exactly one comparison.

Header: <algorithm>

Namespace: std

Show:
© 2014 Microsoft