I would use the second because it indicates the standard!
Two definitions, as others have noted, are equivalent if < defines the general order for both types, and == matches < . But when this is either wrong, the difference is observable, and if you used the first definition that you would not correspond.
EDIT: The standard definition is better than your first definition in one sense: if < defines strict weak ordering on both T1 and T2, then the standard definition gives strict weak ordering on pair<T1, T2> . Your first definition does not, and this can cause real problems. Suppose, for example, that x and y are such that neither x < y nor y < x . Then we consider an array of pairs a[3] = {P(x, 2), P(y, 1), P(x, 1)} . It is clear that we must say that this array is not sorted in ascending order because a[2] < a[0] . But if we use your first definition, std::is_sorted will conclude that the array is sorted, because no two consecutive elements are comparable. The fact that the first definition is not a strict weak order violates the algorithm. In the standard definition, P(y, 1) < P(x, 2) , and therefore the algorithm detects that the array is not sorted as desired.
(This answer previously had a completely incorrect analysis of this situation - sorry!)
source share