@@ -1103,10 +1103,10 @@ $(H2 $(LNAME2 inline-functions, Inline Functions))
1103
1103
1104
1104
$(H2 $(LNAME2 function-overloading, Function Overloading))
1105
1105
1106
- $(P Functions are overloaded based on how well the arguments
1107
- to a function can match up with the parameters .
1108
- The function with the $(I best) match is selected .
1109
- The levels of matching are:
1106
+ $(P $(I Function overloading) occurs when two or more functions in the same scope
1107
+ have the same name .
1108
+ The function selected is the one that is the $(I best match) to the arguments .
1109
+ The matching levels are:
1110
1110
)
1111
1111
1112
1112
$(OL
@@ -1117,27 +1117,26 @@ $(H2 $(LNAME2 function-overloading, Function Overloading))
1117
1117
$(LI exact match)
1118
1118
)
1119
1119
1120
- $(P Each argument (including any $(CODE this) pointer ) is
1121
- compared against the function's corresponding parameter, to
1120
+ $(P Each argument (including any $(CODE this) reference ) is
1121
+ compared against the function's corresponding parameter to
1122
1122
determine the match level for that argument. The match level
1123
1123
for a function is the $(I worst) match level of each of its
1124
1124
arguments.)
1125
1125
1126
1126
$(P Literals do not match $(CODE ref) or $(CODE out) parameters.)
1127
1127
1128
-
1129
1128
$(P If two or more functions have the same match level,
1130
1129
then $(LNAME2 partial-ordering, $(I partial ordering))
1131
- is used to try to find the best match.
1130
+ is used to disambiguate to find the best match.
1132
1131
Partial ordering finds the most specialized function.
1133
1132
If neither function is more specialized than the other,
1134
1133
then it is an ambiguity error.
1135
- Partial ordering is determined for functions $(CODE f() )
1136
- and $(CODE g()) by taking the parameter types of $(CODE f() ),
1134
+ Partial ordering is determined for functions $(I f )
1135
+ and $(I g) by taking the parameter types of $(I f ),
1137
1136
constructing a list of arguments by taking the default values
1138
- of those types, and attempting to match them against $(CODE g() ).
1139
- If it succeeds, then $(CODE g() ) is at least as specialized
1140
- as $(CODE f() ).
1137
+ of those types, and attempting to match them against $(I g ).
1138
+ If it succeeds, then $(I g ) is at least as specialized
1139
+ as $(I f ).
1141
1140
For example:
1142
1141
)
1143
1142
---
@@ -1150,7 +1149,7 @@ void foo(B);
1150
1149
void test()
1151
1150
{
1152
1151
C c;
1153
- /* Both foo(A) and foo(B) match with implicit conversion rules .
1152
+ /* Both foo(A) and foo(B) match with implicit conversions (level 2) .
1154
1153
* Applying partial ordering rules,
1155
1154
* foo(B) cannot be called with an A, and foo(A) can be called
1156
1155
* with a B. Therefore, foo(B) is more specialized, and is selected.
@@ -1163,16 +1162,11 @@ void test()
1163
1162
)
1164
1163
1165
1164
1166
- $(P Functions defined with non-D linkage cannot be overloaded.
1167
- This is because the name mangling might not take the parameter types
1168
- into account.
1169
- )
1170
-
1171
1165
$(H3 $(LNAME2 overload-sets, Overload Sets))
1172
1166
1173
1167
$(P Functions declared at the same scope overload against each
1174
1168
other, and are called an $(I Overload Set).
1175
- A typical example of an overload set are functions defined
1169
+ An example of an overload set are functions defined
1176
1170
at module level:
1177
1171
)
1178
1172
@@ -1185,7 +1179,8 @@ void foo(long i) { }
1185
1179
)
1186
1180
1187
1181
$(P $(CODE A.foo()) and $(CODE A.foo(long)) form an overload set.
1188
- A different module can also define functions with the same name:
1182
+ A different module can also define another overload set of
1183
+ functions with the same name:
1189
1184
)
1190
1185
1191
1186
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
@@ -1199,7 +1194,8 @@ void foo(int i) { }
1199
1194
1200
1195
$(P and A and B can be imported by a third module, C.
1201
1196
Both overload sets, the $(CODE A.foo) overload set and the $(CODE B.foo)
1202
- overload set, are found. An instance of $(CODE foo) is selected
1197
+ overload set, are found when searching for symbol `foo`.
1198
+ An instance of $(CODE foo) is selected
1203
1199
based on it matching in exactly one overload set:
1204
1200
)
1205
1201
@@ -1244,6 +1240,7 @@ void bar(C c)
1244
1240
}
1245
1241
---
1246
1242
1243
+
1247
1244
$(H2 $(LNAME2 parameters, Function Parameters))
1248
1245
1249
1246
$(H3 $(LNAME2 param-storage, Parameter Storage Classes))
0 commit comments