C++ Standard Library lexicographical_compare() Sample

Description

lexicographical_compare() is used to compare two sequences. It returns true only if the first sequence compares < to the second. Comparing two identical sequences will return false.

Declaration

	template <class In, class In2>
	    bool lexicographical_compare(In, In, In2, In2);
	template <class In, class In2, class Cmp>
	    bool lexicographical_compare(In, In, In2, In2, Cmp);

Concept

The sample program first compares two strings, using the builtin comparison operator. Then two vectors are compared, with a user-defined comparison class. In this example, vec1 compares as less than vec2, because the customized comparison function compares according to the absolute magnitude of the respective values.

Supported
Supported
Supported