From Jason Turner

[class.compare.default]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp8iluhhv8/{from.md → to.md} +11 -34
tmp/tmp8iluhhv8/{from.md → to.md} RENAMED
@@ -1,23 +1,19 @@
1
  ### Defaulted comparison operator functions <a id="class.compare.default">[[class.compare.default]]</a>
2
 
3
  A defaulted comparison operator function [[over.binary]] for some class
4
  `C` shall be a non-template function that is
5
 
6
- - a non-static const non-volatile member of `C` having one parameter of
7
- type `const C&` and either no *ref-qualifier* or the *ref-qualifier*
8
- `&`, or
9
- - a friend of `C` having either two parameters of type `const C&` or two
10
- parameters of type `C`.
11
 
12
- A comparison operator function for class `C` that is defaulted on its
13
- first declaration and is not defined as deleted is *implicitly defined*
14
- when it is odr-used or needed for constant evaluation. Name lookups in
15
- the defaulted definition of a comparison operator function are performed
16
- from a context equivalent to its *function-body*. A definition of a
17
- comparison operator as defaulted that appears in a class shall be the
18
- first declaration of that function.
19
 
20
  A defaulted `<=>` or `==` operator function for class `C` is defined as
21
  deleted if any non-static data member of `C` is of reference type or `C`
22
  has variant members [[class.union.anon]].
23
 
@@ -26,47 +22,28 @@ A binary operator expression `a @ b` is *usable* if either
26
  - `a` or `b` is of class or enumeration type and overload resolution
27
  [[over.match]] as applied to `a @ b` results in a usable candidate, or
28
  - neither `a` nor `b` is of class or enumeration type and `a @ b` is a
29
  valid expression.
30
 
31
- A defaulted comparison function is *constexpr-compatible* if it
32
- satisfies the requirements for a constexpr function [[dcl.constexpr]]
33
- and no overload resolution performed when determining whether to delete
34
- the function results in a usable candidate that is a non-constexpr
35
- function.
36
-
37
- [*Note 1*:
38
-
39
- This includes the overload resolutions performed:
40
-
41
- - for an `operator<=>` whose return type is not `auto`, when determining
42
- whether a synthesized three-way comparison is defined,
43
- - for an `operator<=>` whose return type is `auto` or for an
44
- `operator==`, for a comparison between an element of the expanded list
45
- of subobjects and itself, or
46
- - for a secondary comparison operator `@`, for the expression `x @ y`.
47
-
48
- — *end note*]
49
-
50
  If the *member-specification* does not explicitly declare any member or
51
  friend named `operator==`, an `==` operator function is declared
52
  implicitly for each three-way comparison operator function defined as
53
  defaulted in the *member-specification*, with the same access and
54
  *function-definition* and in the same class scope as the respective
55
  three-way comparison operator function, except that the return type is
56
  replaced with `bool` and the *declarator-id* is replaced with
57
  `operator==`.
58
 
59
- [*Note 2*: Such an implicitly-declared `==` operator for a class `X` is
60
  defined as defaulted in the definition of `X` and has the same
61
  *parameter-declaration-clause* and trailing *requires-clause* as the
62
  respective three-way comparison operator. It is declared with `friend`,
63
  `virtual`, `constexpr`, or `consteval` if the three-way comparison
64
  operator function is so declared. If the three-way comparison operator
65
  function has no *noexcept-specifier*, the implicitly-declared `==`
66
  operator function has an implicit exception specification
67
- [[except.spec]] that may differ from the implicit exception
68
  specification of the three-way comparison operator
69
  function. — *end note*]
70
 
71
  [*Example 1*:
72
 
@@ -80,11 +57,11 @@ template<typename T> struct X {
80
  };
81
  ```
82
 
83
  — *end example*]
84
 
85
- [*Note 3*: The `==` operator function is declared implicitly even if
86
  the defaulted three-way comparison operator function is defined as
87
  deleted. — *end note*]
88
 
89
  The direct base class subobjects of `C`, in the order of their
90
  declaration in the *base-specifier-list* of `C`, followed by the
 
1
  ### Defaulted comparison operator functions <a id="class.compare.default">[[class.compare.default]]</a>
2
 
3
  A defaulted comparison operator function [[over.binary]] for some class
4
  `C` shall be a non-template function that is
5
 
6
+ - a non-static member or friend of `C` and
7
+ - either has two parameters of type `const C&` or two parameters of type
8
+ `C`, where the implicit object parameter (if any) is considered to be
9
+ the first parameter.
 
10
 
11
+ Name lookups in the implicit definition [[dcl.fct.def.default]] of a
12
+ comparison operator function are performed from a context equivalent to
13
+ its *function-body*. A definition of a comparison operator as defaulted
14
+ that appears in a class shall be the first declaration of that function.
 
 
 
15
 
16
  A defaulted `<=>` or `==` operator function for class `C` is defined as
17
  deleted if any non-static data member of `C` is of reference type or `C`
18
  has variant members [[class.union.anon]].
19
 
 
22
  - `a` or `b` is of class or enumeration type and overload resolution
23
  [[over.match]] as applied to `a @ b` results in a usable candidate, or
24
  - neither `a` nor `b` is of class or enumeration type and `a @ b` is a
25
  valid expression.
26
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  If the *member-specification* does not explicitly declare any member or
28
  friend named `operator==`, an `==` operator function is declared
29
  implicitly for each three-way comparison operator function defined as
30
  defaulted in the *member-specification*, with the same access and
31
  *function-definition* and in the same class scope as the respective
32
  three-way comparison operator function, except that the return type is
33
  replaced with `bool` and the *declarator-id* is replaced with
34
  `operator==`.
35
 
36
+ [*Note 1*: Such an implicitly-declared `==` operator for a class `X` is
37
  defined as defaulted in the definition of `X` and has the same
38
  *parameter-declaration-clause* and trailing *requires-clause* as the
39
  respective three-way comparison operator. It is declared with `friend`,
40
  `virtual`, `constexpr`, or `consteval` if the three-way comparison
41
  operator function is so declared. If the three-way comparison operator
42
  function has no *noexcept-specifier*, the implicitly-declared `==`
43
  operator function has an implicit exception specification
44
+ [[except.spec]] that can differ from the implicit exception
45
  specification of the three-way comparison operator
46
  function. — *end note*]
47
 
48
  [*Example 1*:
49
 
 
57
  };
58
  ```
59
 
60
  — *end example*]
61
 
62
+ [*Note 2*: The `==` operator function is declared implicitly even if
63
  the defaulted three-way comparison operator function is defined as
64
  deleted. — *end note*]
65
 
66
  The direct base class subobjects of `C`, in the order of their
67
  declaration in the *base-specifier-list* of `C`, followed by the