- tmp/tmp1tmbt6mn/{from.md → to.md} +466 -181
tmp/tmp1tmbt6mn/{from.md → to.md}
RENAMED
|
@@ -1,30 +1,26 @@
|
|
| 1 |
### Candidate functions and argument lists <a id="over.match.funcs">[[over.match.funcs]]</a>
|
| 2 |
|
| 3 |
The subclauses of [[over.match.funcs]] describe the set of candidate
|
| 4 |
functions and the argument list submitted to overload resolution in each
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
constructions.
|
| 10 |
|
| 11 |
The set of candidate functions can contain both member and non-member
|
| 12 |
functions to be resolved against the same argument list. So that
|
| 13 |
argument and parameter lists are comparable within this heterogeneous
|
| 14 |
-
set, a member function is considered to have an extra parameter,
|
| 15 |
-
the *implicit object parameter*, which represents the object for
|
| 16 |
-
the member function has been called. For the purposes of overload
|
| 17 |
resolution, both static and non-static member functions have an implicit
|
| 18 |
object parameter, but constructors do not.
|
| 19 |
|
| 20 |
Similarly, when appropriate, the context can construct an argument list
|
| 21 |
-
that contains an *implied object argument*
|
| 22 |
-
|
| 23 |
-
within their respective lists, the convention is that the implicit
|
| 24 |
-
object parameter, if present, is always the first parameter and the
|
| 25 |
-
implied object argument, if present, is always the first argument.
|
| 26 |
|
| 27 |
For non-static member functions, the type of the implicit object
|
| 28 |
parameter is
|
| 29 |
|
| 30 |
- “lvalue reference to cv `X`” for functions declared without a
|
|
@@ -48,25 +44,25 @@ defining the type of the implicit object parameter. For static member
|
|
| 48 |
functions, the implicit object parameter is considered to match any
|
| 49 |
object (since if the function is selected, the object is discarded).
|
| 50 |
|
| 51 |
[*Note 1*: No actual type is established for the implicit object
|
| 52 |
parameter of a static member function, and no attempt will be made to
|
| 53 |
-
determine a conversion sequence for that parameter
|
| 54 |
-
[[over.match.best]]
|
| 55 |
|
| 56 |
During overload resolution, the implied object argument is
|
| 57 |
indistinguishable from other arguments. The implicit object parameter,
|
| 58 |
however, retains its identity since no user-defined conversions can be
|
| 59 |
applied to achieve a type match with it. For non-static member functions
|
| 60 |
-
declared without a *ref-qualifier*,
|
|
|
|
|
|
|
|
|
|
| 61 |
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
parameter. \[*Note 2*: The fact that such an argument is an rvalue
|
| 66 |
-
does not affect the ranking of implicit conversion sequences (
|
| 67 |
-
[[over.ics.rank]]). — *end note*]
|
| 68 |
|
| 69 |
Because other than in list-initialization only one user-defined
|
| 70 |
conversion is allowed in an implicit conversion sequence, special rules
|
| 71 |
apply when selecting the best user-defined conversion (
|
| 72 |
[[over.match.best]], [[over.best.ics]]).
|
|
@@ -81,46 +77,80 @@ public:
|
|
| 81 |
|
| 82 |
class C : T {
|
| 83 |
public:
|
| 84 |
C(int);
|
| 85 |
};
|
| 86 |
-
T a = 1; //
|
| 87 |
```
|
| 88 |
|
| 89 |
— *end example*]
|
| 90 |
|
| 91 |
In each case where a candidate is a function template, candidate
|
| 92 |
function template specializations are generated using template argument
|
| 93 |
-
deduction ([[temp.over]], [[temp.deduct]]).
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
A
|
| 101 |
-
|
| 102 |
-
functions
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
|
| 104 |
#### Function call syntax <a id="over.match.call">[[over.match.call]]</a>
|
| 105 |
|
| 106 |
-
In a function call
|
| 107 |
|
| 108 |
``` bnf
|
| 109 |
postfix-expression '(' expression-listₒₚₜ ')'
|
| 110 |
```
|
| 111 |
|
| 112 |
-
if the *postfix-expression*
|
| 113 |
-
|
| 114 |
[[over.call.func]]. If the *postfix-expression* denotes an object of
|
| 115 |
class type, overload resolution is applied as specified in
|
| 116 |
[[over.call.object]].
|
| 117 |
|
| 118 |
-
If the *postfix-expression*
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
|
| 123 |
[*Note 1*: The resolution of the address of an overload set in other
|
| 124 |
contexts is described in [[over.over]]. — *end note*]
|
| 125 |
|
| 126 |
##### Call to named function <a id="over.call.func">[[over.call.func]]</a>
|
|
@@ -142,82 +172,75 @@ These represent two syntactic subcategories of function calls: qualified
|
|
| 142 |
function calls and unqualified function calls.
|
| 143 |
|
| 144 |
In qualified function calls, the name to be resolved is an
|
| 145 |
*id-expression* and is preceded by an `->` or `.` operator. Since the
|
| 146 |
construct `A->B` is generally equivalent to `(*A).B`, the rest of
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
|
| 160 |
In unqualified function calls, the name is not qualified by an `->` or
|
| 161 |
`.` operator and has the more general form of a *primary-expression*.
|
| 162 |
The name is looked up in the context of the function call following the
|
| 163 |
-
normal rules for name lookup in
|
| 164 |
function declarations found by that lookup constitute the set of
|
| 165 |
candidate functions. Because of the rules for name lookup, the set of
|
| 166 |
candidate functions consists (1) entirely of non-member functions or (2)
|
| 167 |
entirely of member functions of some class `T`. In case (1), the
|
| 168 |
argument list is the same as the *expression-list* in the call. In case
|
| 169 |
(2), the argument list is the *expression-list* in the call augmented by
|
| 170 |
the addition of an implied object argument as in a qualified function
|
| 171 |
-
call. If the keyword `this`
|
| 172 |
class `T`, or a derived class of `T`, then the implied object argument
|
| 173 |
is `(*this)`. If the keyword `this` is not in scope or refers to another
|
| 174 |
class, then a contrived object of type `T` becomes the implied object
|
| 175 |
-
argument[^4]
|
| 176 |
and overload resolution selects one of the non-static member functions
|
| 177 |
of `T`, the call is ill-formed.
|
| 178 |
|
| 179 |
##### Call to object of class type <a id="over.call.object">[[over.call.object]]</a>
|
| 180 |
|
| 181 |
-
If the *
|
| 182 |
a class object of type “cv `T`”, then the set of candidate functions
|
| 183 |
includes at least the function call operators of `T`. The function call
|
| 184 |
operators of `T` are obtained by ordinary lookup of the name
|
| 185 |
`operator()` in the context of `(E).operator()`.
|
| 186 |
|
| 187 |
In addition, for each non-explicit conversion function declared in `T`
|
| 188 |
of the form
|
| 189 |
|
| 190 |
``` bnf
|
| 191 |
-
|
| 192 |
```
|
| 193 |
|
| 194 |
-
where *cv-qualifier* is the same cv-qualification as,
|
| 195 |
-
cv-qualification than, cv, and where *conversion-type-id*
|
| 196 |
-
type “pointer to function of (`P₁`, …, `Pₙ`) returning `R`”,
|
| 197 |
-
“reference to pointer to function of (`P₁`, …, `Pₙ`)
|
| 198 |
-
the type “reference to function of (`P₁`, …, `Pₙ`)
|
| 199 |
-
*surrogate call function* with the unique name
|
| 200 |
-
having the form
|
| 201 |
|
| 202 |
``` bnf
|
| 203 |
-
'R' call-function '(' conversion-type-id \ %
|
| 204 |
'F, P₁ a₁, …, Pₙ aₙ)' '{ return F (a₁, …, aₙ); }'
|
| 205 |
```
|
| 206 |
|
| 207 |
is also considered as a candidate function. Similarly, surrogate call
|
| 208 |
functions are added to the set of candidate functions for each
|
| 209 |
non-explicit conversion function declared in a base class of `T`
|
| 210 |
provided the function is not hidden within `T` by another intervening
|
| 211 |
-
declaration[^5]
|
| 212 |
-
|
| 213 |
-
If such a surrogate call function is selected by overload resolution,
|
| 214 |
-
the corresponding conversion function will be called to convert `E` to
|
| 215 |
-
the appropriate function pointer or reference, and the function will
|
| 216 |
-
then be invoked with the arguments of the call. If the conversion
|
| 217 |
-
function cannot be called (e.g., because of an ambiguity), the program
|
| 218 |
-
is ill-formed.
|
| 219 |
|
| 220 |
The argument list submitted to overload resolution consists of the
|
| 221 |
argument expressions present in the function call syntax preceded by the
|
| 222 |
implied object argument `(E)`.
|
| 223 |
|
|
@@ -249,18 +272,18 @@ int i = a(1); // calls f1 via pointer returned from conversion
|
|
| 249 |
|
| 250 |
#### Operators in expressions <a id="over.match.oper">[[over.match.oper]]</a>
|
| 251 |
|
| 252 |
If no operand of an operator in an expression has a type that is a class
|
| 253 |
or an enumeration, the operator is assumed to be a built-in operator and
|
| 254 |
-
interpreted according to
|
| 255 |
|
| 256 |
[*Note 1*: Because `.`, `.*`, and `::` cannot be overloaded, these
|
| 257 |
-
operators are always built-in operators interpreted according to
|
| 258 |
-
[[expr]]. `?:` cannot be overloaded, but the rules in this
|
| 259 |
-
used to determine the conversions to be applied to the
|
| 260 |
-
operands when they have class or enumeration type
|
| 261 |
-
[[expr.cond]]
|
| 262 |
|
| 263 |
[*Example 1*:
|
| 264 |
|
| 265 |
``` cpp
|
| 266 |
struct String {
|
|
@@ -269,11 +292,12 @@ struct String {
|
|
| 269 |
operator const char* ();
|
| 270 |
};
|
| 271 |
String operator + (const String&, const String&);
|
| 272 |
|
| 273 |
void f() {
|
| 274 |
-
|
|
|
|
| 275 |
int I = 1 + 1; // always evaluates to 2 even if class or enumeration types exist
|
| 276 |
// that would perform the operation.
|
| 277 |
}
|
| 278 |
```
|
| 279 |
|
|
@@ -284,16 +308,16 @@ user-defined operator function might be declared that implements this
|
|
| 284 |
operator or a user-defined conversion can be necessary to convert the
|
| 285 |
operand to a type that is appropriate for a built-in operator. In this
|
| 286 |
case, overload resolution is used to determine which operator function
|
| 287 |
or built-in operator is to be invoked to implement the operator.
|
| 288 |
Therefore, the operator notation is first transformed to the equivalent
|
| 289 |
-
function-call notation as summarized in
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
| 293 |
|
| 294 |
-
**Table: Relationship between operator and function call notation** <a id="
|
| 295 |
|
| 296 |
| Subclause | Expression | As member function | As non-member function |
|
| 297 |
| ------------ | ---------- | ------------------- | ---------------------- |
|
| 298 |
| (a)} |
|
| 299 |
| (a, b)} |
|
|
@@ -301,25 +325,24 @@ for the built-in operator (Clause [[expr]]).
|
|
| 301 |
| [[over.sub]] | `a[b]` | `(a).operator[](b)` | |
|
| 302 |
| [[over.ref]] | `a->` | `(a).operator->( )` | |
|
| 303 |
| (a, 0)} |
|
| 304 |
|
| 305 |
|
| 306 |
-
For a unary operator `@` with an operand of
|
| 307 |
-
|
| 308 |
-
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
candidates*, are constructed as follows:
|
| 312 |
|
| 313 |
- If `T1` is a complete class type or a class currently being defined,
|
| 314 |
the set of member candidates is the result of the qualified lookup of
|
| 315 |
-
`T1::operator@`
|
| 316 |
candidates is empty.
|
| 317 |
- The set of non-member candidates is the result of the unqualified
|
| 318 |
lookup of `operator@` in the context of the expression according to
|
| 319 |
-
the usual rules for name lookup in unqualified function calls
|
| 320 |
-
[[basic.lookup.argdep]]
|
| 321 |
However, if no operand has a class type, only those non-member
|
| 322 |
functions in the lookup set that have a first parameter of type `T1`
|
| 323 |
or “reference to cv `T1`”, when `T1` is an enumeration type, or (if
|
| 324 |
there is a right operand) a second parameter of type `T2` or
|
| 325 |
“reference to cv `T2`”, when `T2` is an enumeration type, are
|
|
@@ -332,26 +355,48 @@ candidates*, are constructed as follows:
|
|
| 332 |
- accept the same number of operands, and
|
| 333 |
- accept operand types to which the given operand or operands can be
|
| 334 |
converted according to [[over.best.ics]], and
|
| 335 |
- do not have the same parameter-type-list as any non-member candidate
|
| 336 |
that is not a function template specialization.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 337 |
|
| 338 |
For the built-in assignment operators, conversions of the left operand
|
| 339 |
are restricted as follows:
|
| 340 |
|
| 341 |
- no temporaries are introduced to hold the left operand, and
|
| 342 |
- no user-defined conversions are applied to the left operand to achieve
|
| 343 |
a type match with the left-most parameter of a built-in candidate.
|
| 344 |
|
| 345 |
For all other operators, no such restrictions apply.
|
| 346 |
|
| 347 |
-
The set of candidate functions for overload resolution
|
| 348 |
-
the member candidates, the non-member candidates,
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
|
|
|
|
|
|
|
| 353 |
|
| 354 |
[*Example 2*:
|
| 355 |
|
| 356 |
``` cpp
|
| 357 |
struct A {
|
|
@@ -364,17 +409,36 @@ void m() {
|
|
| 364 |
}
|
| 365 |
```
|
| 366 |
|
| 367 |
— *end example*]
|
| 368 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 369 |
If a built-in candidate is selected by overload resolution, the operands
|
| 370 |
of class type are converted to the types of the corresponding parameters
|
| 371 |
of the selected operation function, except that the second standard
|
| 372 |
-
conversion sequence of a user-defined conversion sequence
|
| 373 |
-
[[over.ics.user]]
|
| 374 |
-
corresponding built-in operator and interpreted according to
|
| 375 |
-
[[expr]].
|
| 376 |
|
| 377 |
[*Example 3*:
|
| 378 |
|
| 379 |
``` cpp
|
| 380 |
struct X {
|
|
@@ -396,14 +460,14 @@ The second operand of operator `->` is ignored in selecting an
|
|
| 396 |
function is called. When `operator->` returns, the operator `->` is
|
| 397 |
applied to the value returned, with the original second operand.[^7]
|
| 398 |
|
| 399 |
If the operator is the operator `,`, the unary operator `&`, or the
|
| 400 |
operator `->`, and there are no viable functions, then the operator is
|
| 401 |
-
assumed to be the built-in operator and interpreted according to
|
| 402 |
-
[[expr]].
|
| 403 |
|
| 404 |
-
[*Note
|
| 405 |
|
| 406 |
The lookup rules for operators in expressions are different than the
|
| 407 |
lookup rules for operator function names in a function call, as shown in
|
| 408 |
the following example:
|
| 409 |
|
|
@@ -426,19 +490,20 @@ void B::f() {
|
|
| 426 |
|
| 427 |
— *end note*]
|
| 428 |
|
| 429 |
#### Initialization by constructor <a id="over.match.ctor">[[over.match.ctor]]</a>
|
| 430 |
|
| 431 |
-
When objects of class type are direct-initialized
|
| 432 |
-
copy-initialized from an expression of the same or a derived class
|
| 433 |
-
|
| 434 |
-
|
| 435 |
default-initialization that is not in the context of
|
| 436 |
copy-initialization, the candidate functions are all the constructors of
|
| 437 |
-
the class of the object being initialized. For copy-initialization
|
| 438 |
-
|
| 439 |
-
|
|
|
|
| 440 |
*expression-list* or *assignment-expression* of the *initializer*.
|
| 441 |
|
| 442 |
#### Copy-initialization of class by user-defined conversion <a id="over.match.copy">[[over.match.copy]]</a>
|
| 443 |
|
| 444 |
Under the conditions specified in [[dcl.init]], as part of a
|
|
@@ -452,25 +517,25 @@ to a possibly cv-qualified class type is determined in terms of a
|
|
| 452 |
corresponding non-reference copy-initialization. — *end note*]
|
| 453 |
|
| 454 |
Assuming that “*cv1* `T`” is the type of the object being initialized,
|
| 455 |
with `T` a class type, the candidate functions are selected as follows:
|
| 456 |
|
| 457 |
-
- The converting constructors
|
| 458 |
-
|
| 459 |
- When the type of the initializer expression is a class type “cv `S`”,
|
| 460 |
the non-explicit conversion functions of `S` and its base classes are
|
| 461 |
-
considered. When initializing a temporary
|
| 462 |
-
parameter of a constructor where the parameter is
|
| 463 |
-
|
| 464 |
single argument in the context of direct-initialization of an object
|
| 465 |
-
of type “*
|
| 466 |
considered. Those that are not hidden within `S` and yield a type
|
| 467 |
whose cv-unqualified version is the same type as `T` or is a derived
|
| 468 |
-
class thereof are candidate functions.
|
| 469 |
-
|
| 470 |
-
|
| 471 |
-
|
| 472 |
|
| 473 |
In both cases, the argument list has one argument, which is the
|
| 474 |
initializer expression.
|
| 475 |
|
| 476 |
[*Note 2*: This argument will be compared against the first parameter
|
|
@@ -489,120 +554,226 @@ the initializer expression, with `S` a class type, the candidate
|
|
| 489 |
functions are selected as follows:
|
| 490 |
|
| 491 |
- The conversion functions of `S` and its base classes are considered.
|
| 492 |
Those non-explicit conversion functions that are not hidden within `S`
|
| 493 |
and yield type `T` or a type that can be converted to type `T` via a
|
| 494 |
-
standard conversion sequence
|
| 495 |
-
|
| 496 |
-
|
| 497 |
-
|
| 498 |
-
|
| 499 |
-
|
| 500 |
-
|
| 501 |
-
|
| 502 |
-
|
| 503 |
-
|
| 504 |
-
of selecting candidate functions.
|
| 505 |
|
| 506 |
The argument list has one argument, which is the initializer expression.
|
| 507 |
|
| 508 |
[*Note 1*: This argument will be compared against the implicit object
|
| 509 |
parameter of the conversion functions. — *end note*]
|
| 510 |
|
| 511 |
#### Initialization by conversion function for direct reference binding <a id="over.match.ref">[[over.match.ref]]</a>
|
| 512 |
|
| 513 |
Under the conditions specified in [[dcl.init.ref]], a reference can be
|
| 514 |
-
bound directly to
|
| 515 |
-
|
| 516 |
-
|
| 517 |
-
|
| 518 |
-
|
| 519 |
-
|
| 520 |
-
as follows:
|
| 521 |
|
| 522 |
- The conversion functions of `S` and its base classes are considered.
|
| 523 |
Those non-explicit conversion functions that are not hidden within `S`
|
| 524 |
and yield type “lvalue reference to *cv2* `T2`” (when initializing an
|
| 525 |
lvalue reference or an rvalue reference to function) or “*cv2* `T2`”
|
| 526 |
or “rvalue reference to *cv2* `T2`” (when initializing an rvalue
|
| 527 |
reference or an lvalue reference to function), where “*cv1* `T`” is
|
| 528 |
-
reference-compatible
|
| 529 |
-
|
| 530 |
-
|
| 531 |
-
|
| 532 |
-
|
| 533 |
-
|
| 534 |
-
|
|
|
|
|
|
|
| 535 |
|
| 536 |
The argument list has one argument, which is the initializer expression.
|
| 537 |
|
| 538 |
[*Note 1*: This argument will be compared against the implicit object
|
| 539 |
parameter of the conversion functions. — *end note*]
|
| 540 |
|
| 541 |
#### Initialization by list-initialization <a id="over.match.list">[[over.match.list]]</a>
|
| 542 |
|
| 543 |
When objects of non-aggregate class type `T` are list-initialized such
|
| 544 |
that [[dcl.init.list]] specifies that overload resolution is performed
|
| 545 |
-
according to the rules in this
|
| 546 |
-
|
|
|
|
| 547 |
|
| 548 |
-
-
|
| 549 |
-
|
| 550 |
-
|
| 551 |
-
|
| 552 |
-
|
| 553 |
-
|
| 554 |
-
|
|
|
|
|
|
|
| 555 |
|
| 556 |
-
|
| 557 |
-
|
| 558 |
-
an `explicit` constructor is chosen, the initialization is ill-formed.
|
| 559 |
|
| 560 |
-
[*Note 1*: This differs from other situations
|
| 561 |
[[over.match.copy]]), where only converting constructors are considered
|
| 562 |
for copy-initialization. This restriction only applies if this
|
| 563 |
initialization is part of the final result of overload
|
| 564 |
resolution. — *end note*]
|
| 565 |
|
| 566 |
#### Class template argument deduction <a id="over.match.class.deduct">[[over.match.class.deduct]]</a>
|
| 567 |
|
| 568 |
-
|
|
|
|
|
|
|
|
|
|
| 569 |
|
| 570 |
-
-
|
| 571 |
-
|
| 572 |
-
the
|
| 573 |
-
|
| 574 |
-
|
| 575 |
-
template arguments) of the constructor, if any.
|
| 576 |
- The types of the function parameters are those of the constructor.
|
| 577 |
- The return type is the class template specialization designated by
|
| 578 |
-
|
| 579 |
-
|
| 580 |
-
- If
|
| 581 |
-
|
| 582 |
-
|
| 583 |
- An additional function template derived as above from a hypothetical
|
| 584 |
constructor `C(C)`, called the *copy deduction candidate*.
|
| 585 |
- For each *deduction-guide*, a function or function template with the
|
| 586 |
following properties:
|
| 587 |
- The template parameters, if any, and function parameters are those
|
| 588 |
of the *deduction-guide*.
|
| 589 |
- The return type is the *simple-template-id* of the
|
| 590 |
*deduction-guide*.
|
| 591 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 592 |
Initialization and overload resolution are performed as described in
|
| 593 |
[[dcl.init]] and [[over.match.ctor]], [[over.match.copy]], or
|
| 594 |
[[over.match.list]] (as appropriate for the type of initialization
|
| 595 |
-
performed) for an object of a hypothetical class type, where the
|
| 596 |
-
|
| 597 |
constructors of that class type for the purpose of forming an overload
|
| 598 |
set, and the initializer is provided by the context in which class
|
| 599 |
-
template argument deduction was performed.
|
| 600 |
-
|
| 601 |
-
|
| 602 |
-
|
| 603 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 604 |
|
| 605 |
[*Example 1*:
|
| 606 |
|
| 607 |
``` cpp
|
| 608 |
template <class T> struct A {
|
|
@@ -630,9 +801,123 @@ template <class T> struct B {
|
|
| 630 |
template <class U> using TA = T;
|
| 631 |
template <class U> B(U, TA<U>);
|
| 632 |
};
|
| 633 |
|
| 634 |
B b{(int*)0, (char*)0}; // OK, deduces B<char*>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 635 |
```
|
| 636 |
|
| 637 |
— *end example*]
|
| 638 |
|
|
|
|
| 1 |
### Candidate functions and argument lists <a id="over.match.funcs">[[over.match.funcs]]</a>
|
| 2 |
|
| 3 |
The subclauses of [[over.match.funcs]] describe the set of candidate
|
| 4 |
functions and the argument list submitted to overload resolution in each
|
| 5 |
+
context in which overload resolution is used. The source transformations
|
| 6 |
+
and constructions defined in these subclauses are only for the purpose
|
| 7 |
+
of describing the overload resolution process. An implementation is not
|
| 8 |
+
required to use such transformations and constructions.
|
|
|
|
| 9 |
|
| 10 |
The set of candidate functions can contain both member and non-member
|
| 11 |
functions to be resolved against the same argument list. So that
|
| 12 |
argument and parameter lists are comparable within this heterogeneous
|
| 13 |
+
set, a member function is considered to have an extra first parameter,
|
| 14 |
+
called the *implicit object parameter*, which represents the object for
|
| 15 |
+
which the member function has been called. For the purposes of overload
|
| 16 |
resolution, both static and non-static member functions have an implicit
|
| 17 |
object parameter, but constructors do not.
|
| 18 |
|
| 19 |
Similarly, when appropriate, the context can construct an argument list
|
| 20 |
+
that contains an *implied object argument* as the first argument in the
|
| 21 |
+
list to denote the object to be operated on.
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
For non-static member functions, the type of the implicit object
|
| 24 |
parameter is
|
| 25 |
|
| 26 |
- “lvalue reference to cv `X`” for functions declared without a
|
|
|
|
| 44 |
functions, the implicit object parameter is considered to match any
|
| 45 |
object (since if the function is selected, the object is discarded).
|
| 46 |
|
| 47 |
[*Note 1*: No actual type is established for the implicit object
|
| 48 |
parameter of a static member function, and no attempt will be made to
|
| 49 |
+
determine a conversion sequence for that parameter
|
| 50 |
+
[[over.match.best]]. — *end note*]
|
| 51 |
|
| 52 |
During overload resolution, the implied object argument is
|
| 53 |
indistinguishable from other arguments. The implicit object parameter,
|
| 54 |
however, retains its identity since no user-defined conversions can be
|
| 55 |
applied to achieve a type match with it. For non-static member functions
|
| 56 |
+
declared without a *ref-qualifier*, even if the implicit object
|
| 57 |
+
parameter is not const-qualified, an rvalue can be bound to the
|
| 58 |
+
parameter as long as in all other respects the argument can be converted
|
| 59 |
+
to the type of the implicit object parameter.
|
| 60 |
|
| 61 |
+
[*Note 2*: The fact that such an argument is an rvalue does not affect
|
| 62 |
+
the ranking of implicit conversion sequences
|
| 63 |
+
[[over.ics.rank]]. — *end note*]
|
|
|
|
|
|
|
|
|
|
| 64 |
|
| 65 |
Because other than in list-initialization only one user-defined
|
| 66 |
conversion is allowed in an implicit conversion sequence, special rules
|
| 67 |
apply when selecting the best user-defined conversion (
|
| 68 |
[[over.match.best]], [[over.best.ics]]).
|
|
|
|
| 77 |
|
| 78 |
class C : T {
|
| 79 |
public:
|
| 80 |
C(int);
|
| 81 |
};
|
| 82 |
+
T a = 1; // error: no viable conversion (T(C(1)) not considered)
|
| 83 |
```
|
| 84 |
|
| 85 |
— *end example*]
|
| 86 |
|
| 87 |
In each case where a candidate is a function template, candidate
|
| 88 |
function template specializations are generated using template argument
|
| 89 |
+
deduction ([[temp.over]], [[temp.deduct]]). If a constructor template
|
| 90 |
+
or conversion function template has an *explicit-specifier* whose
|
| 91 |
+
*constant-expression* is value-dependent [[temp.dep]], template argument
|
| 92 |
+
deduction is performed first and then, if the context requires a
|
| 93 |
+
candidate that is not explicit and the generated specialization is
|
| 94 |
+
explicit [[dcl.fct.spec]], it will be removed from the candidate set.
|
| 95 |
+
Those candidates are then handled as candidate functions in the usual
|
| 96 |
+
way.[^2] A given name can refer to one or more function templates and
|
| 97 |
+
also to a set of non-template functions. In such a case, the candidate
|
| 98 |
+
functions generated from each function template are combined with the
|
| 99 |
+
set of non-template candidate functions.
|
| 100 |
+
|
| 101 |
+
A defaulted move special member function ([[class.copy.ctor]],
|
| 102 |
+
[[class.copy.assign]]) that is defined as deleted is excluded from the
|
| 103 |
+
set of candidate functions in all contexts. A constructor inherited from
|
| 104 |
+
class type `C` [[class.inhctor.init]] that has a first parameter of type
|
| 105 |
+
“reference to *cv1* `P`” (including such a constructor instantiated from
|
| 106 |
+
a template) is excluded from the set of candidate functions when
|
| 107 |
+
constructing an object of type *cv2* `D` if the argument list has
|
| 108 |
+
exactly one argument and `C` is reference-related to `P` and `P` is
|
| 109 |
+
reference-related to `D`.
|
| 110 |
+
|
| 111 |
+
[*Example 3*:
|
| 112 |
+
|
| 113 |
+
``` cpp
|
| 114 |
+
struct A {
|
| 115 |
+
A(); // #1
|
| 116 |
+
A(A &&); // #2
|
| 117 |
+
template<typename T> A(T &&); // #3
|
| 118 |
+
};
|
| 119 |
+
struct B : A {
|
| 120 |
+
using A::A;
|
| 121 |
+
B(const B &); // #4
|
| 122 |
+
B(B &&) = default; // #5, implicitly deleted
|
| 123 |
+
|
| 124 |
+
struct X { X(X &&) = delete; } x;
|
| 125 |
+
};
|
| 126 |
+
extern B b1;
|
| 127 |
+
B b2 = static_cast<B&&>(b1); // calls #4: #1 is not viable, #2, #3, and #5 are not candidates
|
| 128 |
+
struct C { operator B&&(); };
|
| 129 |
+
B b3 = C(); // calls #4
|
| 130 |
+
```
|
| 131 |
+
|
| 132 |
+
— *end example*]
|
| 133 |
|
| 134 |
#### Function call syntax <a id="over.match.call">[[over.match.call]]</a>
|
| 135 |
|
| 136 |
+
In a function call [[expr.call]]
|
| 137 |
|
| 138 |
``` bnf
|
| 139 |
postfix-expression '(' expression-listₒₚₜ ')'
|
| 140 |
```
|
| 141 |
|
| 142 |
+
if the *postfix-expression* names at least one function or function
|
| 143 |
+
template, overload resolution is applied as specified in
|
| 144 |
[[over.call.func]]. If the *postfix-expression* denotes an object of
|
| 145 |
class type, overload resolution is applied as specified in
|
| 146 |
[[over.call.object]].
|
| 147 |
|
| 148 |
+
If the *postfix-expression* is the address of an overload set, overload
|
| 149 |
+
resolution is applied using that set as described above. If the function
|
| 150 |
+
selected by overload resolution is a non-static member function, the
|
| 151 |
+
program is ill-formed.
|
| 152 |
|
| 153 |
[*Note 1*: The resolution of the address of an overload set in other
|
| 154 |
contexts is described in [[over.over]]. — *end note*]
|
| 155 |
|
| 156 |
##### Call to named function <a id="over.call.func">[[over.call.func]]</a>
|
|
|
|
| 172 |
function calls and unqualified function calls.
|
| 173 |
|
| 174 |
In qualified function calls, the name to be resolved is an
|
| 175 |
*id-expression* and is preceded by an `->` or `.` operator. Since the
|
| 176 |
construct `A->B` is generally equivalent to `(*A).B`, the rest of
|
| 177 |
+
[[over]] assumes, without loss of generality, that all member function
|
| 178 |
+
calls have been normalized to the form that uses an object and the `.`
|
| 179 |
+
operator. Furthermore, [[over]] assumes that the *postfix-expression*
|
| 180 |
+
that is the left operand of the `.` operator has type “cv `T`” where `T`
|
| 181 |
+
denotes a class.[^3] Under this assumption, the *id-expression* in the
|
| 182 |
+
call is looked up as a member function of `T` following the rules for
|
| 183 |
+
looking up names in classes [[class.member.lookup]]. The function
|
| 184 |
+
declarations found by that lookup constitute the set of candidate
|
| 185 |
+
functions. The argument list is the *expression-list* in the call
|
| 186 |
+
augmented by the addition of the left operand of the `.` operator in the
|
| 187 |
+
normalized member function call as the implied object argument
|
| 188 |
+
[[over.match.funcs]].
|
| 189 |
|
| 190 |
In unqualified function calls, the name is not qualified by an `->` or
|
| 191 |
`.` operator and has the more general form of a *primary-expression*.
|
| 192 |
The name is looked up in the context of the function call following the
|
| 193 |
+
normal rules for name lookup in expressions [[basic.lookup]]. The
|
| 194 |
function declarations found by that lookup constitute the set of
|
| 195 |
candidate functions. Because of the rules for name lookup, the set of
|
| 196 |
candidate functions consists (1) entirely of non-member functions or (2)
|
| 197 |
entirely of member functions of some class `T`. In case (1), the
|
| 198 |
argument list is the same as the *expression-list* in the call. In case
|
| 199 |
(2), the argument list is the *expression-list* in the call augmented by
|
| 200 |
the addition of an implied object argument as in a qualified function
|
| 201 |
+
call. If the keyword `this` [[class.this]] is in scope and refers to
|
| 202 |
class `T`, or a derived class of `T`, then the implied object argument
|
| 203 |
is `(*this)`. If the keyword `this` is not in scope or refers to another
|
| 204 |
class, then a contrived object of type `T` becomes the implied object
|
| 205 |
+
argument.[^4] If the argument list is augmented by a contrived object
|
| 206 |
and overload resolution selects one of the non-static member functions
|
| 207 |
of `T`, the call is ill-formed.
|
| 208 |
|
| 209 |
##### Call to object of class type <a id="over.call.object">[[over.call.object]]</a>
|
| 210 |
|
| 211 |
+
If the *postfix-expression* `E` in the function call syntax evaluates to
|
| 212 |
a class object of type “cv `T`”, then the set of candidate functions
|
| 213 |
includes at least the function call operators of `T`. The function call
|
| 214 |
operators of `T` are obtained by ordinary lookup of the name
|
| 215 |
`operator()` in the context of `(E).operator()`.
|
| 216 |
|
| 217 |
In addition, for each non-explicit conversion function declared in `T`
|
| 218 |
of the form
|
| 219 |
|
| 220 |
``` bnf
|
| 221 |
+
operator conversion-type-id '( )' cv-qualifier-seqₒₚₜ ref-qualifierₒₚₜ noexcept-specifierₒₚₜ attribute-specifier-seqₒₚₜ ';'
|
| 222 |
```
|
| 223 |
|
| 224 |
+
where the optional *cv-qualifier-seq* is the same cv-qualification as,
|
| 225 |
+
or a greater cv-qualification than, cv, and where *conversion-type-id*
|
| 226 |
+
denotes the type “pointer to function of (`P₁`, …, `Pₙ`) returning `R`”,
|
| 227 |
+
or the type “reference to pointer to function of (`P₁`, …, `Pₙ`)
|
| 228 |
+
returning `R`”, or the type “reference to function of (`P₁`, …, `Pₙ`)
|
| 229 |
+
returning `R`”, a *surrogate call function* with the unique name
|
| 230 |
+
*call-function* and having the form
|
| 231 |
|
| 232 |
``` bnf
|
| 233 |
+
'R' *call-function* '(' conversion-type-id \ %
|
| 234 |
'F, P₁ a₁, …, Pₙ aₙ)' '{ return F (a₁, …, aₙ); }'
|
| 235 |
```
|
| 236 |
|
| 237 |
is also considered as a candidate function. Similarly, surrogate call
|
| 238 |
functions are added to the set of candidate functions for each
|
| 239 |
non-explicit conversion function declared in a base class of `T`
|
| 240 |
provided the function is not hidden within `T` by another intervening
|
| 241 |
+
declaration.[^5]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 242 |
|
| 243 |
The argument list submitted to overload resolution consists of the
|
| 244 |
argument expressions present in the function call syntax preceded by the
|
| 245 |
implied object argument `(E)`.
|
| 246 |
|
|
|
|
| 272 |
|
| 273 |
#### Operators in expressions <a id="over.match.oper">[[over.match.oper]]</a>
|
| 274 |
|
| 275 |
If no operand of an operator in an expression has a type that is a class
|
| 276 |
or an enumeration, the operator is assumed to be a built-in operator and
|
| 277 |
+
interpreted according to [[expr.compound]].
|
| 278 |
|
| 279 |
[*Note 1*: Because `.`, `.*`, and `::` cannot be overloaded, these
|
| 280 |
+
operators are always built-in operators interpreted according to
|
| 281 |
+
[[expr.compound]]. `?:` cannot be overloaded, but the rules in this
|
| 282 |
+
subclause are used to determine the conversions to be applied to the
|
| 283 |
+
second and third operands when they have class or enumeration type
|
| 284 |
+
[[expr.cond]]. — *end note*]
|
| 285 |
|
| 286 |
[*Example 1*:
|
| 287 |
|
| 288 |
``` cpp
|
| 289 |
struct String {
|
|
|
|
| 292 |
operator const char* ();
|
| 293 |
};
|
| 294 |
String operator + (const String&, const String&);
|
| 295 |
|
| 296 |
void f() {
|
| 297 |
+
const char* p= "one" + "two"; // error: cannot add two pointers; overloaded operator+ not considered
|
| 298 |
+
// because neither operand has class or enumeration type
|
| 299 |
int I = 1 + 1; // always evaluates to 2 even if class or enumeration types exist
|
| 300 |
// that would perform the operation.
|
| 301 |
}
|
| 302 |
```
|
| 303 |
|
|
|
|
| 308 |
operator or a user-defined conversion can be necessary to convert the
|
| 309 |
operand to a type that is appropriate for a built-in operator. In this
|
| 310 |
case, overload resolution is used to determine which operator function
|
| 311 |
or built-in operator is to be invoked to implement the operator.
|
| 312 |
Therefore, the operator notation is first transformed to the equivalent
|
| 313 |
+
function-call notation as summarized in [[over.match.oper]] (where `@`
|
| 314 |
+
denotes one of the operators covered in the specified subclause).
|
| 315 |
+
However, the operands are sequenced in the order prescribed for the
|
| 316 |
+
built-in operator [[expr.compound]].
|
| 317 |
|
| 318 |
+
**Table: Relationship between operator and function call notation** <a id="over.match.oper">[over.match.oper]</a>
|
| 319 |
|
| 320 |
| Subclause | Expression | As member function | As non-member function |
|
| 321 |
| ------------ | ---------- | ------------------- | ---------------------- |
|
| 322 |
| (a)} |
|
| 323 |
| (a, b)} |
|
|
|
|
| 325 |
| [[over.sub]] | `a[b]` | `(a).operator[](b)` | |
|
| 326 |
| [[over.ref]] | `a->` | `(a).operator->( )` | |
|
| 327 |
| (a, 0)} |
|
| 328 |
|
| 329 |
|
| 330 |
+
For a unary operator `@` with an operand of type *cv1* `T1`, and for a
|
| 331 |
+
binary operator `@` with a left operand of type *cv1* `T1` and a right
|
| 332 |
+
operand of type *cv2* `T2`, four sets of candidate functions, designated
|
| 333 |
+
*member candidates*, *non-member candidates*, *built-in candidates*, and
|
| 334 |
+
*rewritten candidates*, are constructed as follows:
|
|
|
|
| 335 |
|
| 336 |
- If `T1` is a complete class type or a class currently being defined,
|
| 337 |
the set of member candidates is the result of the qualified lookup of
|
| 338 |
+
`T1::operator@` [[over.call.func]]; otherwise, the set of member
|
| 339 |
candidates is empty.
|
| 340 |
- The set of non-member candidates is the result of the unqualified
|
| 341 |
lookup of `operator@` in the context of the expression according to
|
| 342 |
+
the usual rules for name lookup in unqualified function calls
|
| 343 |
+
[[basic.lookup.argdep]] except that all member functions are ignored.
|
| 344 |
However, if no operand has a class type, only those non-member
|
| 345 |
functions in the lookup set that have a first parameter of type `T1`
|
| 346 |
or “reference to cv `T1`”, when `T1` is an enumeration type, or (if
|
| 347 |
there is a right operand) a second parameter of type `T2` or
|
| 348 |
“reference to cv `T2`”, when `T2` is an enumeration type, are
|
|
|
|
| 355 |
- accept the same number of operands, and
|
| 356 |
- accept operand types to which the given operand or operands can be
|
| 357 |
converted according to [[over.best.ics]], and
|
| 358 |
- do not have the same parameter-type-list as any non-member candidate
|
| 359 |
that is not a function template specialization.
|
| 360 |
+
- The rewritten candidate set is determined as follows:
|
| 361 |
+
- For the relational [[expr.rel]] operators, the rewritten candidates
|
| 362 |
+
include all non-rewritten candidates for the expression `x <=> y`.
|
| 363 |
+
- For the relational [[expr.rel]] and three-way comparison
|
| 364 |
+
[[expr.spaceship]] operators, the rewritten candidates also include
|
| 365 |
+
a synthesized candidate, with the order of the two parameters
|
| 366 |
+
reversed, for each non-rewritten candidate for the expression
|
| 367 |
+
`y <=> x`.
|
| 368 |
+
- For the `!=` operator [[expr.eq]], the rewritten candidates include
|
| 369 |
+
all non-rewritten candidates for the expression `x == y`.
|
| 370 |
+
- For the equality operators, the rewritten candidates also include a
|
| 371 |
+
synthesized candidate, with the order of the two parameters
|
| 372 |
+
reversed, for each non-rewritten candidate for the expression
|
| 373 |
+
`y == x`.
|
| 374 |
+
- For all other operators, the rewritten candidate set is empty.
|
| 375 |
+
|
| 376 |
+
\[*Note 2*: A candidate synthesized from a member candidate has its
|
| 377 |
+
implicit object parameter as the second parameter, thus implicit
|
| 378 |
+
conversions are considered for the first, but not for the second,
|
| 379 |
+
parameter. — *end note*]
|
| 380 |
|
| 381 |
For the built-in assignment operators, conversions of the left operand
|
| 382 |
are restricted as follows:
|
| 383 |
|
| 384 |
- no temporaries are introduced to hold the left operand, and
|
| 385 |
- no user-defined conversions are applied to the left operand to achieve
|
| 386 |
a type match with the left-most parameter of a built-in candidate.
|
| 387 |
|
| 388 |
For all other operators, no such restrictions apply.
|
| 389 |
|
| 390 |
+
The set of candidate functions for overload resolution for some operator
|
| 391 |
+
`@` is the union of the member candidates, the non-member candidates,
|
| 392 |
+
the built-in candidates, and the rewritten candidates for that operator
|
| 393 |
+
`@`.
|
| 394 |
+
|
| 395 |
+
The argument list contains all of the operands of the operator. The best
|
| 396 |
+
function from the set of candidate functions is selected according to
|
| 397 |
+
[[over.match.viable]] and [[over.match.best]].[^6]
|
| 398 |
|
| 399 |
[*Example 2*:
|
| 400 |
|
| 401 |
``` cpp
|
| 402 |
struct A {
|
|
|
|
| 409 |
}
|
| 410 |
```
|
| 411 |
|
| 412 |
— *end example*]
|
| 413 |
|
| 414 |
+
If a rewritten `operator<=>` candidate is selected by overload
|
| 415 |
+
resolution for an operator `@`, `x @ y` is interpreted as
|
| 416 |
+
`0 @ (y <=> x)` if the selected candidate is a synthesized candidate
|
| 417 |
+
with reversed order of parameters, or `(x <=> y) @ 0` otherwise, using
|
| 418 |
+
the selected rewritten `operator<=>` candidate. Rewritten candidates for
|
| 419 |
+
the operator `@` are not considered in the context of the resulting
|
| 420 |
+
expression.
|
| 421 |
+
|
| 422 |
+
If a rewritten `operator==` candidate is selected by overload resolution
|
| 423 |
+
for an operator `@`, its return type shall be cv `bool`, and `x @ y` is
|
| 424 |
+
interpreted as:
|
| 425 |
+
|
| 426 |
+
- if `@` is `!=` and the selected candidate is a synthesized candidate
|
| 427 |
+
with reversed order of parameters, `!(y == x)`,
|
| 428 |
+
- otherwise, if `@` is `!=`, `!(x == y)`,
|
| 429 |
+
- otherwise (when `@` is `==`), `y == x`,
|
| 430 |
+
|
| 431 |
+
in each case using the selected rewritten `operator==` candidate.
|
| 432 |
+
|
| 433 |
If a built-in candidate is selected by overload resolution, the operands
|
| 434 |
of class type are converted to the types of the corresponding parameters
|
| 435 |
of the selected operation function, except that the second standard
|
| 436 |
+
conversion sequence of a user-defined conversion sequence
|
| 437 |
+
[[over.ics.user]] is not applied. Then the operator is treated as the
|
| 438 |
+
corresponding built-in operator and interpreted according to
|
| 439 |
+
[[expr.compound]].
|
| 440 |
|
| 441 |
[*Example 3*:
|
| 442 |
|
| 443 |
``` cpp
|
| 444 |
struct X {
|
|
|
|
| 460 |
function is called. When `operator->` returns, the operator `->` is
|
| 461 |
applied to the value returned, with the original second operand.[^7]
|
| 462 |
|
| 463 |
If the operator is the operator `,`, the unary operator `&`, or the
|
| 464 |
operator `->`, and there are no viable functions, then the operator is
|
| 465 |
+
assumed to be the built-in operator and interpreted according to
|
| 466 |
+
[[expr.compound]].
|
| 467 |
|
| 468 |
+
[*Note 3*:
|
| 469 |
|
| 470 |
The lookup rules for operators in expressions are different than the
|
| 471 |
lookup rules for operator function names in a function call, as shown in
|
| 472 |
the following example:
|
| 473 |
|
|
|
|
| 490 |
|
| 491 |
— *end note*]
|
| 492 |
|
| 493 |
#### Initialization by constructor <a id="over.match.ctor">[[over.match.ctor]]</a>
|
| 494 |
|
| 495 |
+
When objects of class type are direct-initialized [[dcl.init]],
|
| 496 |
+
copy-initialized from an expression of the same or a derived class type
|
| 497 |
+
[[dcl.init]], or default-initialized [[dcl.init]], overload resolution
|
| 498 |
+
selects the constructor. For direct-initialization or
|
| 499 |
default-initialization that is not in the context of
|
| 500 |
copy-initialization, the candidate functions are all the constructors of
|
| 501 |
+
the class of the object being initialized. For copy-initialization
|
| 502 |
+
(including default initialization in the context of
|
| 503 |
+
copy-initialization), the candidate functions are all the converting
|
| 504 |
+
constructors [[class.conv.ctor]] of that class. The argument list is the
|
| 505 |
*expression-list* or *assignment-expression* of the *initializer*.
|
| 506 |
|
| 507 |
#### Copy-initialization of class by user-defined conversion <a id="over.match.copy">[[over.match.copy]]</a>
|
| 508 |
|
| 509 |
Under the conditions specified in [[dcl.init]], as part of a
|
|
|
|
| 517 |
corresponding non-reference copy-initialization. — *end note*]
|
| 518 |
|
| 519 |
Assuming that “*cv1* `T`” is the type of the object being initialized,
|
| 520 |
with `T` a class type, the candidate functions are selected as follows:
|
| 521 |
|
| 522 |
+
- The converting constructors [[class.conv.ctor]] of `T` are candidate
|
| 523 |
+
functions.
|
| 524 |
- When the type of the initializer expression is a class type “cv `S`”,
|
| 525 |
the non-explicit conversion functions of `S` and its base classes are
|
| 526 |
+
considered. When initializing a temporary object [[class.mem]] to be
|
| 527 |
+
bound to the first parameter of a constructor where the parameter is
|
| 528 |
+
of type “reference to *cv2* `T`” and the constructor is called with a
|
| 529 |
single argument in the context of direct-initialization of an object
|
| 530 |
+
of type “*cv3* `T`”, explicit conversion functions are also
|
| 531 |
considered. Those that are not hidden within `S` and yield a type
|
| 532 |
whose cv-unqualified version is the same type as `T` or is a derived
|
| 533 |
+
class thereof are candidate functions. A call to a conversion function
|
| 534 |
+
returning “reference to `X`” is a glvalue of type `X`, and such a
|
| 535 |
+
conversion function is therefore considered to yield `X` for this
|
| 536 |
+
process of selecting candidate functions.
|
| 537 |
|
| 538 |
In both cases, the argument list has one argument, which is the
|
| 539 |
initializer expression.
|
| 540 |
|
| 541 |
[*Note 2*: This argument will be compared against the first parameter
|
|
|
|
| 554 |
functions are selected as follows:
|
| 555 |
|
| 556 |
- The conversion functions of `S` and its base classes are considered.
|
| 557 |
Those non-explicit conversion functions that are not hidden within `S`
|
| 558 |
and yield type `T` or a type that can be converted to type `T` via a
|
| 559 |
+
standard conversion sequence [[over.ics.scs]] are candidate functions.
|
| 560 |
+
For direct-initialization, those explicit conversion functions that
|
| 561 |
+
are not hidden within `S` and yield type `T` or a type that can be
|
| 562 |
+
converted to type `T` with a qualification conversion [[conv.qual]]
|
| 563 |
+
are also candidate functions. Conversion functions that return a
|
| 564 |
+
cv-qualified type are considered to yield the cv-unqualified version
|
| 565 |
+
of that type for this process of selecting candidate functions. A call
|
| 566 |
+
to a conversion function returning “reference to `X`” is a glvalue of
|
| 567 |
+
type `X`, and such a conversion function is therefore considered to
|
| 568 |
+
yield `X` for this process of selecting candidate functions.
|
|
|
|
| 569 |
|
| 570 |
The argument list has one argument, which is the initializer expression.
|
| 571 |
|
| 572 |
[*Note 1*: This argument will be compared against the implicit object
|
| 573 |
parameter of the conversion functions. — *end note*]
|
| 574 |
|
| 575 |
#### Initialization by conversion function for direct reference binding <a id="over.match.ref">[[over.match.ref]]</a>
|
| 576 |
|
| 577 |
Under the conditions specified in [[dcl.init.ref]], a reference can be
|
| 578 |
+
bound directly to the result of applying a conversion function to an
|
| 579 |
+
initializer expression. Overload resolution is used to select the
|
| 580 |
+
conversion function to be invoked. Assuming that “reference to *cv1*
|
| 581 |
+
`T`” is the type of the reference being initialized, and “cv `S`” is the
|
| 582 |
+
type of the initializer expression, with `S` a class type, the candidate
|
| 583 |
+
functions are selected as follows:
|
|
|
|
| 584 |
|
| 585 |
- The conversion functions of `S` and its base classes are considered.
|
| 586 |
Those non-explicit conversion functions that are not hidden within `S`
|
| 587 |
and yield type “lvalue reference to *cv2* `T2`” (when initializing an
|
| 588 |
lvalue reference or an rvalue reference to function) or “*cv2* `T2`”
|
| 589 |
or “rvalue reference to *cv2* `T2`” (when initializing an rvalue
|
| 590 |
reference or an lvalue reference to function), where “*cv1* `T`” is
|
| 591 |
+
reference-compatible [[dcl.init.ref]] with “*cv2* `T2`”, are candidate
|
| 592 |
+
functions. For direct-initialization, those explicit conversion
|
| 593 |
+
functions that are not hidden within `S` and yield type “lvalue
|
| 594 |
+
reference to *cv2* `T2`” (when initializing an lvalue reference or an
|
| 595 |
+
rvalue reference to function) or “rvalue reference to *cv2* `T2`”
|
| 596 |
+
(when initializing an rvalue reference or an lvalue reference to
|
| 597 |
+
function), where `T2` is the same type as `T` or can be converted to
|
| 598 |
+
type `T` with a qualification conversion [[conv.qual]], are also
|
| 599 |
+
candidate functions.
|
| 600 |
|
| 601 |
The argument list has one argument, which is the initializer expression.
|
| 602 |
|
| 603 |
[*Note 1*: This argument will be compared against the implicit object
|
| 604 |
parameter of the conversion functions. — *end note*]
|
| 605 |
|
| 606 |
#### Initialization by list-initialization <a id="over.match.list">[[over.match.list]]</a>
|
| 607 |
|
| 608 |
When objects of non-aggregate class type `T` are list-initialized such
|
| 609 |
that [[dcl.init.list]] specifies that overload resolution is performed
|
| 610 |
+
according to the rules in this subclause or when forming a
|
| 611 |
+
list-initialization sequence according to [[over.ics.list]], overload
|
| 612 |
+
resolution selects the constructor in two phases:
|
| 613 |
|
| 614 |
+
- If the initializer list is not empty or `T` has no default
|
| 615 |
+
constructor, overload resolution is first performed where the
|
| 616 |
+
candidate functions are the initializer-list constructors
|
| 617 |
+
[[dcl.init.list]] of the class `T` and the argument list consists of
|
| 618 |
+
the initializer list as a single argument.
|
| 619 |
+
- Otherwise, or if no viable initializer-list constructor is found,
|
| 620 |
+
overload resolution is performed again, where the candidate functions
|
| 621 |
+
are all the constructors of the class `T` and the argument list
|
| 622 |
+
consists of the elements of the initializer list.
|
| 623 |
|
| 624 |
+
In copy-list-initialization, if an explicit constructor is chosen, the
|
| 625 |
+
initialization is ill-formed.
|
|
|
|
| 626 |
|
| 627 |
+
[*Note 1*: This differs from other situations ([[over.match.ctor]],
|
| 628 |
[[over.match.copy]]), where only converting constructors are considered
|
| 629 |
for copy-initialization. This restriction only applies if this
|
| 630 |
initialization is part of the final result of overload
|
| 631 |
resolution. — *end note*]
|
| 632 |
|
| 633 |
#### Class template argument deduction <a id="over.match.class.deduct">[[over.match.class.deduct]]</a>
|
| 634 |
|
| 635 |
+
When resolving a placeholder for a deduced class type
|
| 636 |
+
[[dcl.type.class.deduct]] where the *template-name* names a primary
|
| 637 |
+
class template `C`, a set of functions and function templates, called
|
| 638 |
+
the guides of `C`, is formed comprising:
|
| 639 |
|
| 640 |
+
- If `C` is defined, for each constructor of `C`, a function template
|
| 641 |
+
with the following properties:
|
| 642 |
+
- The template parameters are the template parameters of `C` followed
|
| 643 |
+
by the template parameters (including default template arguments) of
|
| 644 |
+
the constructor, if any.
|
|
|
|
| 645 |
- The types of the function parameters are those of the constructor.
|
| 646 |
- The return type is the class template specialization designated by
|
| 647 |
+
`C` and template arguments corresponding to the template parameters
|
| 648 |
+
of `C`.
|
| 649 |
+
- If `C` is not defined or does not declare any constructors, an
|
| 650 |
+
additional function template derived as above from a hypothetical
|
| 651 |
+
constructor `C()`.
|
| 652 |
- An additional function template derived as above from a hypothetical
|
| 653 |
constructor `C(C)`, called the *copy deduction candidate*.
|
| 654 |
- For each *deduction-guide*, a function or function template with the
|
| 655 |
following properties:
|
| 656 |
- The template parameters, if any, and function parameters are those
|
| 657 |
of the *deduction-guide*.
|
| 658 |
- The return type is the *simple-template-id* of the
|
| 659 |
*deduction-guide*.
|
| 660 |
|
| 661 |
+
In addition, if `C` is defined and its definition satisfies the
|
| 662 |
+
conditions for an aggregate class [[dcl.init.aggr]] with the assumption
|
| 663 |
+
that any dependent base class has no virtual functions and no virtual
|
| 664 |
+
base classes, and the initializer is a non-empty *braced-init-list* or
|
| 665 |
+
parenthesized *expression-list*, and there are no *deduction-guide*s for
|
| 666 |
+
`C`, the set contains an additional function template, called the
|
| 667 |
+
*aggregate deduction candidate*, defined as follows. Let x₁, …, xₙ be
|
| 668 |
+
the elements of the *initializer-list* or *designated-initializer-list*
|
| 669 |
+
of the *braced-init-list*, or of the *expression-list*. For each xᵢ, let
|
| 670 |
+
eᵢ be the corresponding aggregate element of `C` or of one of its
|
| 671 |
+
(possibly recursive) subaggregates that would be initialized by xᵢ
|
| 672 |
+
[[dcl.init.aggr]] if
|
| 673 |
+
|
| 674 |
+
- brace elision is not considered for any aggregate element that has a
|
| 675 |
+
dependent non-array type or an array type with a value-dependent
|
| 676 |
+
bound, and
|
| 677 |
+
- each non-trailing aggregate element that is a pack expansion is
|
| 678 |
+
assumed to correspond to no elements of the initializer list, and
|
| 679 |
+
- a trailing aggregate element that is a pack expansion is assumed to
|
| 680 |
+
correspond to all remaining elements of the initializer list (if any).
|
| 681 |
+
|
| 682 |
+
If there is no such aggregate element eᵢ for any xᵢ, the aggregate
|
| 683 |
+
deduction candidate is not added to the set. The aggregate deduction
|
| 684 |
+
candidate is derived as above from a hypothetical constructor
|
| 685 |
+
`C`(`T₁`, …, `Tₙ`), where
|
| 686 |
+
|
| 687 |
+
- if eᵢ is of array type and xᵢ is a *braced-init-list* or
|
| 688 |
+
*string-literal*, `Tᵢ` is an rvalue reference to the declared type of
|
| 689 |
+
eᵢ, and
|
| 690 |
+
- otherwise, `Tᵢ` is the declared type of eᵢ,
|
| 691 |
+
|
| 692 |
+
except that additional parameter packs of the form `Pⱼ` `...` are
|
| 693 |
+
inserted into the parameter list in their original aggregate element
|
| 694 |
+
position corresponding to each non-trailing aggregate element of type
|
| 695 |
+
`Pⱼ` that was skipped because it was a parameter pack, and the trailing
|
| 696 |
+
sequence of parameters corresponding to a trailing aggregate element
|
| 697 |
+
that is a pack expansion (if any) is replaced by a single parameter of
|
| 698 |
+
the form `Tₙ` `...`.
|
| 699 |
+
|
| 700 |
+
When resolving a placeholder for a deduced class type
|
| 701 |
+
[[dcl.type.simple]] where the *template-name* names an alias template
|
| 702 |
+
`A`, the *defining-type-id* of `A` must be of the form
|
| 703 |
+
|
| 704 |
+
``` bnf
|
| 705 |
+
typenameₒₚₜ nested-name-specifierₒₚₜ templateₒₚₜ simple-template-id
|
| 706 |
+
```
|
| 707 |
+
|
| 708 |
+
as specified in [[dcl.type.simple]]. The guides of `A` are the set of
|
| 709 |
+
functions or function templates formed as follows. For each function or
|
| 710 |
+
function template `f` in the guides of the template named by the
|
| 711 |
+
*simple-template-id* of the *defining-type-id*, the template arguments
|
| 712 |
+
of the return type of `f` are deduced from the *defining-type-id* of `A`
|
| 713 |
+
according to the process in [[temp.deduct.type]] with the exception that
|
| 714 |
+
deduction does not fail if not all template arguments are deduced. Let
|
| 715 |
+
`g` denote the result of substituting these deductions into `f`. If
|
| 716 |
+
substitution succeeds, form a function or function template `f'` with
|
| 717 |
+
the following properties and add it to the set of guides of `A`:
|
| 718 |
+
|
| 719 |
+
- The function type of `f'` is the function type of `g`.
|
| 720 |
+
- If `f` is a function template, `f'` is a function template whose
|
| 721 |
+
template parameter list consists of all the template parameters of `A`
|
| 722 |
+
(including their default template arguments) that appear in the above
|
| 723 |
+
deductions or (recursively) in their default template arguments,
|
| 724 |
+
followed by the template parameters of `f` that were not deduced
|
| 725 |
+
(including their default template arguments), otherwise `f'` is not a
|
| 726 |
+
function template.
|
| 727 |
+
- The associated constraints [[temp.constr.decl]] are the conjunction of
|
| 728 |
+
the associated constraints of `g` and a constraint that is satisfied
|
| 729 |
+
if and only if the arguments of `A` are deducible (see below) from the
|
| 730 |
+
return type.
|
| 731 |
+
- If `f` is a copy deduction candidate [[over.match.class.deduct]], then
|
| 732 |
+
`f'` is considered to be so as well.
|
| 733 |
+
- If `f` was generated from a *deduction-guide*
|
| 734 |
+
[[over.match.class.deduct]], then `f'` is considered to be so as well.
|
| 735 |
+
- The *explicit-specifier* of `f'` is the *explicit-specifier* of `g`
|
| 736 |
+
(if any).
|
| 737 |
+
|
| 738 |
+
The arguments of a template `A` are said to be deducible from a type `T`
|
| 739 |
+
if, given a class template
|
| 740 |
+
|
| 741 |
+
``` cpp
|
| 742 |
+
template <typename> class AA;
|
| 743 |
+
```
|
| 744 |
+
|
| 745 |
+
with a single partial specialization whose template parameter list is
|
| 746 |
+
that of `A` and whose template argument list is a specialization of `A`
|
| 747 |
+
with the template argument list of `A` [[temp.dep.type]], `AA<T>`
|
| 748 |
+
matches the partial specialization.
|
| 749 |
+
|
| 750 |
Initialization and overload resolution are performed as described in
|
| 751 |
[[dcl.init]] and [[over.match.ctor]], [[over.match.copy]], or
|
| 752 |
[[over.match.list]] (as appropriate for the type of initialization
|
| 753 |
+
performed) for an object of a hypothetical class type, where the guides
|
| 754 |
+
of the template named by the placeholder are considered to be the
|
| 755 |
constructors of that class type for the purpose of forming an overload
|
| 756 |
set, and the initializer is provided by the context in which class
|
| 757 |
+
template argument deduction was performed. The following exceptions
|
| 758 |
+
apply:
|
| 759 |
+
|
| 760 |
+
- The first phase in [[over.match.list]] (considering initializer-list
|
| 761 |
+
constructors) is omitted if the initializer list consists of a single
|
| 762 |
+
expression of type cv `U`, where `U` is, or is derived from, a
|
| 763 |
+
specialization of the class template directly or indirectly named by
|
| 764 |
+
the placeholder.
|
| 765 |
+
- During template argument deduction for the aggregate deduction
|
| 766 |
+
candidate, the number of elements in a trailing parameter pack is only
|
| 767 |
+
deduced from the number of remaining function arguments if it is not
|
| 768 |
+
otherwise deduced.
|
| 769 |
+
|
| 770 |
+
If the function or function template was generated from a constructor or
|
| 771 |
+
*deduction-guide* that had an *explicit-specifier*, each such notional
|
| 772 |
+
constructor is considered to have that same *explicit-specifier*. All
|
| 773 |
+
such notional constructors are considered to be public members of the
|
| 774 |
+
hypothetical class type.
|
| 775 |
|
| 776 |
[*Example 1*:
|
| 777 |
|
| 778 |
``` cpp
|
| 779 |
template <class T> struct A {
|
|
|
|
| 801 |
template <class U> using TA = T;
|
| 802 |
template <class U> B(U, TA<U>);
|
| 803 |
};
|
| 804 |
|
| 805 |
B b{(int*)0, (char*)0}; // OK, deduces B<char*>
|
| 806 |
+
|
| 807 |
+
template <typename T>
|
| 808 |
+
struct S {
|
| 809 |
+
T x;
|
| 810 |
+
T y;
|
| 811 |
+
};
|
| 812 |
+
|
| 813 |
+
template <typename T>
|
| 814 |
+
struct C {
|
| 815 |
+
S<T> s;
|
| 816 |
+
T t;
|
| 817 |
+
};
|
| 818 |
+
|
| 819 |
+
template <typename T>
|
| 820 |
+
struct D {
|
| 821 |
+
S<int> s;
|
| 822 |
+
T t;
|
| 823 |
+
};
|
| 824 |
+
|
| 825 |
+
C c1 = {1, 2}; // error: deduction failed
|
| 826 |
+
C c2 = {1, 2, 3}; // error: deduction failed
|
| 827 |
+
C c3 = {{1u, 2u}, 3}; // OK, deduces C<int>
|
| 828 |
+
|
| 829 |
+
D d1 = {1, 2}; // error: deduction failed
|
| 830 |
+
D d2 = {1, 2, 3}; // OK, braces elided, deduces D<int>
|
| 831 |
+
|
| 832 |
+
template <typename T>
|
| 833 |
+
struct E {
|
| 834 |
+
T t;
|
| 835 |
+
decltype(t) t2;
|
| 836 |
+
};
|
| 837 |
+
|
| 838 |
+
E e1 = {1, 2}; // OK, deduces E<int>
|
| 839 |
+
|
| 840 |
+
template <typename... T>
|
| 841 |
+
struct Types {};
|
| 842 |
+
|
| 843 |
+
template <typename... T>
|
| 844 |
+
struct F : Types<T...>, T... {};
|
| 845 |
+
|
| 846 |
+
struct X {};
|
| 847 |
+
struct Y {};
|
| 848 |
+
struct Z {};
|
| 849 |
+
struct W { operator Y(); };
|
| 850 |
+
|
| 851 |
+
F f1 = {Types<X, Y, Z>{}, {}, {}}; // OK, F<X, Y, Z> deduced
|
| 852 |
+
F f2 = {Types<X, Y, Z>{}, X{}, Y{}}; // OK, F<X, Y, Z> deduced
|
| 853 |
+
F f3 = {Types<X, Y, Z>{}, X{}, W{}}; // error: conflicting types deduced; operator Y not considered
|
| 854 |
+
```
|
| 855 |
+
|
| 856 |
+
— *end example*]
|
| 857 |
+
|
| 858 |
+
[*Example 2*:
|
| 859 |
+
|
| 860 |
+
``` cpp
|
| 861 |
+
template <class T, class U> struct C {
|
| 862 |
+
C(T, U); // #1
|
| 863 |
+
};
|
| 864 |
+
template<class T, class U>
|
| 865 |
+
C(T, U) -> C<T, std::type_identity_t<U>>; // #2
|
| 866 |
+
|
| 867 |
+
template<class V> using A = C<V *, V *>;
|
| 868 |
+
template<std::integral W> using B = A<W>;
|
| 869 |
+
|
| 870 |
+
int i{};
|
| 871 |
+
double d{};
|
| 872 |
+
A a1(&i, &i); // deduces A<int>
|
| 873 |
+
A a2(i, i); // error: cannot deduce V * from i
|
| 874 |
+
A a3(&i, &d); // error: #1: cannot deduce (V*, V*) from (int *, double *)
|
| 875 |
+
// #2: cannot deduce A<V> from C<int *, double *>
|
| 876 |
+
B b1(&i, &i); // deduces B<int>
|
| 877 |
+
B b2(&d, &d); // error: cannot deduce B<W> from C<double *, double *>
|
| 878 |
+
```
|
| 879 |
+
|
| 880 |
+
Possible exposition-only implementation of the above procedure:
|
| 881 |
+
|
| 882 |
+
``` cpp
|
| 883 |
+
// The following concept ensures a specialization of A is deduced.
|
| 884 |
+
template <class> class AA;
|
| 885 |
+
template <class V> class AA<A<V>> { };
|
| 886 |
+
template <class T> concept deduces_A = requires { sizeof(AA<T>); };
|
| 887 |
+
|
| 888 |
+
// f1 is formed from the constructor #1 of C, generating the following function template
|
| 889 |
+
template<T, U>
|
| 890 |
+
auto f1(T, U) -> C<T, U>;
|
| 891 |
+
|
| 892 |
+
// Deducing arguments for C<T, U> from C<V *, V*> deduces T as V * and U as V *;
|
| 893 |
+
// f1' is obtained by transforming f1 as described by the above procedure.
|
| 894 |
+
template<class V> requires deduces_A<C<V *, V *>>
|
| 895 |
+
auto f1_prime(V *, V*) -> C<V *, V *>;
|
| 896 |
+
|
| 897 |
+
// f2 is formed from the deduction-guide #2 of C
|
| 898 |
+
template<class T, class U> auto f2(T, U) -> C<T, std::type_identity_t<U>>;
|
| 899 |
+
|
| 900 |
+
// Deducing arguments for C<T, std::type_identity_t<U>> from C<V *, V*> deduces T as V *;
|
| 901 |
+
// f2' is obtained by transforming f2 as described by the above procedure.
|
| 902 |
+
template<class V, class U>
|
| 903 |
+
requires deduces_A<C<V *, std::type_identity_t<U>>>
|
| 904 |
+
auto f2_prime(V *, U) -> C<V *, std::type_identity_t<U>>;
|
| 905 |
+
|
| 906 |
+
// The following concept ensures a specialization of B is deduced.
|
| 907 |
+
template <class> class BB;
|
| 908 |
+
template <class V> class BB<B<V>> { };
|
| 909 |
+
template <class T> concept deduces_B = requires { sizeof(BB<T>); };
|
| 910 |
+
|
| 911 |
+
// The guides for B derived from the above f1' and f2' for A are as follows:
|
| 912 |
+
template<std::integral W>
|
| 913 |
+
requires deduces_A<C<W *, W *>> && deduces_B<C<W *, W *>>
|
| 914 |
+
auto f1_prime_for_B(W *, W *) -> C<W *, W *>;
|
| 915 |
+
|
| 916 |
+
template<std::integral W, class U>
|
| 917 |
+
requires deduces_A<C<W *, std::type_identity_t<U>>> &&
|
| 918 |
+
deduces_B<C<W *, std::type_identity_t<U>>>
|
| 919 |
+
auto f2_prime_for_B(W *, U) -> C<W *, std::type_identity_t<U>>;
|
| 920 |
```
|
| 921 |
|
| 922 |
— *end example*]
|
| 923 |
|