From Jason Turner

[over.oper]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp4jo6uzxi/{from.md → to.md} +19 -23
tmp/tmp4jo6uzxi/{from.md → to.md} RENAMED
@@ -15,10 +15,11 @@ operator-function-id:
15
  operator operator
16
  ```
17
 
18
  ``` bnf
19
  %% Ed. note: character protrusion would misalign various operators.
 
20
  operator: one of
21
  'new delete new[] delete[] co_await ( ) [ ] -> ->*'
22
  '~ ! + - * / % ^ &'
23
  '| = += -= *= /= %= ^= &='
24
  '|= == != < > <= >= <=> &&'
@@ -73,44 +74,39 @@ explicitly stated in  [[basic.stc.dynamic]].
73
 
74
  The `co_await` operator is described completely in  [[expr.await]]. The
75
  attributes and restrictions found in the rest of [[over.oper]] do not
76
  apply to it unless explicitly stated in  [[expr.await]].
77
 
78
- An operator function shall either
79
-
80
- - be a member function or
81
- - be a non-member function that has at least one non-object parameter
82
- whose type is a class, a reference to a class, an enumeration, or a
83
- reference to an enumeration.
84
-
85
- It is not possible to change the precedence, grouping, or number of
86
- operands of operators. The meaning of the operators `=`, (unary) `&`,
87
- and `,` (comma), predefined for each type, can be changed for specific
88
- class types by defining operator functions that implement these
89
- operators. Likewise, the meaning of the operators (unary) `&` and `,`
90
- (comma) can be changed for specific enumeration types. Operator
91
- functions are inherited in the same manner as other base class
92
- functions.
93
 
94
  An operator function shall be a prefix unary, binary, function call,
95
  subscripting, class member access, increment, or decrement operator
96
  function.
97
 
98
  [*Note 3*: The identities among certain predefined operators applied to
99
- basic types (for example, `++a` ≡ `a+=1`) need not hold for operator
100
- functions. Some predefined operators, such as `+=`, require an operand
101
- to be an lvalue when applied to basic types; this is not required by
102
- operator functions. — *end note*]
103
 
104
  An operator function cannot have default arguments [[dcl.fct.default]],
105
  except where explicitly stated below. Operator functions cannot have
106
  more or fewer parameters than the number required for the corresponding
107
  operator, as described in the rest of [[over.oper]].
108
 
109
- Operators not mentioned explicitly in subclauses  [[over.ass]] through 
110
- [[over.inc]] act as ordinary unary and binary operators obeying the
111
- rules of  [[over.unary]] or  [[over.binary]].
112
 
113
  ### Unary operators <a id="over.unary">[[over.unary]]</a>
114
 
115
  A *prefix unary operator function* is a function named `operator@` for a
116
  prefix *unary-operator* `@` [[expr.unary.op]] that is either a
@@ -168,11 +164,11 @@ function for a relational operator [[expr.rel]]. A
168
  three-way comparison operator [[expr.spaceship]]. A
169
  *comparison operator function* is an equality operator function, a
170
  relational operator function, or a three-way comparison operator
171
  function.
172
 
173
- #### Simple assignment <a id="over.ass">[[over.ass]]</a>
174
 
175
  A *simple assignment operator function* is a binary operator function
176
  named `operator=`. A simple assignment operator function shall be a
177
  non-static member function.
178
 
 
15
  operator operator
16
  ```
17
 
18
  ``` bnf
19
  %% Ed. note: character protrusion would misalign various operators.
20
+
21
  operator: one of
22
  'new delete new[] delete[] co_await ( ) [ ] -> ->*'
23
  '~ ! + - * / % ^ &'
24
  '| = += -= *= /= %= ^= &='
25
  '|= == != < > <= >= <=> &&'
 
74
 
75
  The `co_await` operator is described completely in  [[expr.await]]. The
76
  attributes and restrictions found in the rest of [[over.oper]] do not
77
  apply to it unless explicitly stated in  [[expr.await]].
78
 
79
+ An operator function shall have at least one function parameter or
80
+ implicit object parameter whose type is a class, a reference to a class,
81
+ an enumeration, or a reference to an enumeration. It is not possible to
82
+ change the precedence, grouping, or number of operands of operators. The
83
+ meaning of the operators `=`, (unary) `&`, and `,` (comma), predefined
84
+ for each type, can be changed for specific class types by defining
85
+ operator functions that implement these operators. Likewise, the meaning
86
+ of the operators (unary) `&` and `,` (comma) can be changed for specific
87
+ enumeration types. Operator functions are inherited in the same manner
88
+ as other base class functions.
 
 
 
 
 
89
 
90
  An operator function shall be a prefix unary, binary, function call,
91
  subscripting, class member access, increment, or decrement operator
92
  function.
93
 
94
  [*Note 3*: The identities among certain predefined operators applied to
95
+ fundamental types (for example, `++a` ≡ `a+=1`) need not hold for
96
+ operator functions. Some predefined operators, such as `+=`, require an
97
+ operand to be an lvalue when applied to fundamental types; this is not
98
+ required by operator functions. — *end note*]
99
 
100
  An operator function cannot have default arguments [[dcl.fct.default]],
101
  except where explicitly stated below. Operator functions cannot have
102
  more or fewer parameters than the number required for the corresponding
103
  operator, as described in the rest of [[over.oper]].
104
 
105
+ Operators not mentioned explicitly in subclauses  [[over.assign]]
106
+ through  [[over.inc]] act as ordinary unary and binary operators obeying
107
+ the rules of  [[over.unary]] or  [[over.binary]].
108
 
109
  ### Unary operators <a id="over.unary">[[over.unary]]</a>
110
 
111
  A *prefix unary operator function* is a function named `operator@` for a
112
  prefix *unary-operator* `@` [[expr.unary.op]] that is either a
 
164
  three-way comparison operator [[expr.spaceship]]. A
165
  *comparison operator function* is an equality operator function, a
166
  relational operator function, or a three-way comparison operator
167
  function.
168
 
169
+ #### Simple assignment <a id="over.assign">[[over.assign]]</a>
170
 
171
  A *simple assignment operator function* is a binary operator function
172
  named `operator=`. A simple assignment operator function shall be a
173
  non-static member function.
174