C++ Standard Library max_element() Sample

Description

max_element() is used to find the maximum element in a sequence. The default ordering uses the built-in operator <, and the user can optionally supply a comparison function.

Declaration

	template <class For>
	    For max_element(For, For);
	template <class For, class Cmp>
	    For max_element(For, For, Cmp);

Concept

The maximum value (100) in the vector of five elements is computed and displayed. Then, with the user-defined comparison function specified, the ordering is reversed, and the minimum value (-59) is printed.

Supported
Supported
Supported