C++ Standard Library max() Sample

Description

max() computes the maximum of two values. An optional user-defined comparison can be supplied to control the ordering.

Declaration

	template <class T>
	    const T& max(const T&, const T&);
	template <class T, class Cmp>
	    const T& max(const T&, const T&, Cmp);

Concept

The sample calls max() twice, once to perform a standard computation of the maximum of two integer values, and once to compute the maximum based on a user-supplied comparison. In the first case, the value 37 is printed, because it is greater than -47. In the second case, the absolute magnitude is used for making the comparison, and -47 is printed.

Supported
Supported
Supported