[cmp.categories.pre] (original) (raw)

17 Language support library [support]

17.11 Comparisons [cmp]

17.11.2 Comparison category types [cmp.categories]

17.11.2.1 Preamble [cmp.categories.pre]

The typespartial_­ordering,weak_­ordering, andstrong_­orderingare collectively termed the comparison category types.

Each is specified in terms of an exposition-only data member named valuewhose value typically corresponds to that of an enumerator from one of the following exposition-only enumerations:

enum class eq { equal = 0, equivalent = equal, nonequal = 1, nonequivalent = nonequal }; // exposition only enum class ord { less = -1, greater = 1 }; // exposition only enum class ncmp { unordered = -127 }; // exposition only

[ Note

:

The type strong_­orderingcorresponds to the term total ordering in mathematics.

end note

]

The relational and equality operators for the comparison category types are specified with an anonymous parameter of unspecified type.

This type shall be selected by the implementation such that these parameters can accept literal 0 as a corresponding argument.

[ Example

:

nullptr_­tmeets this requirement.

end example

]

In this context, the behavior of a program that supplies an argument other than a literal 0 is undefined.

For the purposes of subclause [cmp.categories],substitutability is the property that f(a) == f(b) is truewhenever a == b is true, where f denotes a function that reads only comparison-salient state that is accessible via the argument's public const members.