|
|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
The type must work with< operator and the result should have standard semantics.
Contents |
The typeT satisfiesLessThanComparable if given expressionsa,b andc of typeT orconst T(since C++11), the following expression is valid and has its specified effects:
| Expression | Type | Effects |
|---|---|---|
| a< b | meetsBooleanTestable (until C++20) | Establishesstrict weak ordering relation with the following properties:
|
modelsboolean-testable(since C++20) |
To satisfy this requirement, types that do not have built-incomparison operators have to provide auser-definedoperator<.
For the types that are bothEqualityComparable andLessThanComparable, the C++ standard library makes a distinction between
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
| DR | Applied to | Behavior as published | Correct behavior |
|---|---|---|---|
| LWG 2114 (P2167R3) | C++98 | convertibility tobool was too weak to reflect the expectation of implementations | requirements strengthened |
| aBinaryPredicate that establishes an ordering relation (named requirement) | |
(C++20) | specifies that arelation imposes a strict weak ordering(concept)[edit] |