Expression Precondition Semantics
Equality x == y x and y are in the domain of ==
Inequality x != y x and y are in the domain of == Equivalent to !(x == y)
Invariants
Identity &x == &y implies x == y
Reflexivity x == x
Symmetry x == y implies y == x
Transitivity x == y and y == z implies x == z
Models

• int

• vector<int>

See also

LessThanComparable.

LessThan Comparable

Category: utilities

Component type: concept

Description

A type is LessThanComparable if it is ordered: it must be possible to compare two objects of that type using operator<, and operator< must be a partial ordering.

Notation

X A type that is a model of LessThanComparable

x, y, z Object of type X

Definitions

Consider the relation !(x < y) && !(y < x). If this relation is transitive (that is, if !(x < y) && !(y < x) && !(y < z) && !(z < y) implies !(x < z) && !(z < x)), then it satisfies the mathematical definition of an equivalence relation. In this case, operator< is a strict weak ordering.

If operator< is a strict weak ordering, and if each equivalence class has only a single element, then operator< is a total ordering.

Valid expressions
Name Expression Return type
Less x < y Convertible to bool
Greater x > y Convertible to bool
Less or equal x <= y Convertible to bool
Greater or equal x >= y Convertible to bool
Expression semantics
Name
Добавить отзыв
ВСЕ ОТЗЫВЫ О КНИГЕ В ИЗБРАННОЕ

0

Вы можете отметить интересные вам фрагменты текста, которые будут доступны по уникальной ссылке в адресной строке браузера.

Отметить Добавить цитату