mirror of
https://github.com/isocpp/CppCoreGuidelines.git
synced 2025-12-17 04:44:34 +03:00
Add '<=>' to comparison operators related rules (C.87, C.167) (#1759)
* Add '<=>' to comparison operators related rules (C.87, C.167) C++20's three-way comparison operator should respect the same rules as other comparison operators. * Fix a minor typo Co-authored-by: Jonathan Wakely <github@kayari.org> Co-authored-by: Jonathan Wakely <github@kayari.org>
This commit is contained in:
@@ -6562,11 +6562,11 @@ Of course there are ways of making `==` work in a hierarchy, but the naive appro
|
|||||||
|
|
||||||
##### Note
|
##### Note
|
||||||
|
|
||||||
This rule applies to all the usual comparison operators: `!=`, `<`, `<=`, `>`, and `>=`.
|
This rule applies to all the usual comparison operators: `!=`, `<`, `<=`, `>`, `>=`, and `<=>`.
|
||||||
|
|
||||||
##### Enforcement
|
##### Enforcement
|
||||||
|
|
||||||
* Flag a virtual `operator==()`; same for other comparison operators: `!=`, `<`, `<=`, `>`, and `>=`.
|
* Flag a virtual `operator==()`; same for other comparison operators: `!=`, `<`, `<=`, `>`, `>=`, and `<=>`.
|
||||||
|
|
||||||
### <a name="Rc-hash"></a>C.89: Make a `hash` `noexcept`
|
### <a name="Rc-hash"></a>C.89: Make a `hash` `noexcept`
|
||||||
|
|
||||||
@@ -8344,9 +8344,9 @@ By itself, `cout_my_class` would be OK, but it is not usable/composable with cod
|
|||||||
|
|
||||||
##### Note
|
##### Note
|
||||||
|
|
||||||
There are strong and vigorous conventions for the meaning most operators, such as
|
There are strong and vigorous conventions for the meaning of most operators, such as
|
||||||
|
|
||||||
* comparisons (`==`, `!=`, `<`, `<=`, `>`, and `>=`),
|
* comparisons (`==`, `!=`, `<`, `<=`, `>`, `>=`, and `<=>`),
|
||||||
* arithmetic operations (`+`, `-`, `*`, `/`, and `%`)
|
* arithmetic operations (`+`, `-`, `*`, `/`, and `%`)
|
||||||
* access operations (`.`, `->`, unary `*`, and `[]`)
|
* access operations (`.`, `->`, unary `*`, and `[]`)
|
||||||
* assignment (`=`)
|
* assignment (`=`)
|
||||||
|
|||||||
Reference in New Issue
Block a user