| 1 2 3 4 5 6 |
|
This avoids the necessity to declare all six relational operators for every complete type; By defining just two: operator== and operator<, and importing this namespace, all six operators will be defined for the type.
Still, because non-template functions take precedence over template functions, any of these operators may be defined with a different behavior for a specific type, even with rel_ops being used.
Template parameters
- T
- For operator!=, the type shall be EqualityComparable.
A type is EqualityComparable when it supports operator== operations that follow the typical reflexive, symmetric and transitive properties of equalities.
For operator>, operator<=, and perator>=, the type must be LessThanComparable.
A type is LessThanComparable when it supports operator< operations that define a valid strict weak ordering relation.
Example
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
|
Output:
(a<b) is true (a>b) is false |
Because we used rel_ops, all types for which operator< is defined (like vector2d) also have operator>.
See also
| utility | Utility components (header) |
