66 lines
2.8 KiB
Markdown
66 lines
2.8 KiB
Markdown
[over.ics.user]
|
||
|
||
# 12 Overloading [[over]](./#over)
|
||
|
||
## 12.2 Overload resolution [[over.match]](over.match#over.ics.user)
|
||
|
||
### 12.2.4 Best viable function [[over.match.best]](over.match.best#over.ics.user)
|
||
|
||
#### 12.2.4.2 Implicit conversion sequences [[over.best.ics]](over.best.ics#over.ics.user)
|
||
|
||
#### 12.2.4.2.3 User-defined conversion sequences [over.ics.user]
|
||
|
||
[1](#1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/overloading.tex#L2339)
|
||
|
||
A [*user-defined conversion sequence*](#def:conversion_sequence,user-defined "12.2.4.2.3 User-defined conversion sequences [over.ics.user]") consists of an initial
|
||
standard conversion sequence followed by a user-defined
|
||
conversion ([[class.conv]](class.conv "11.4.8 Conversions")) followed by a second standard
|
||
conversion sequence[.](#1.sentence-1)
|
||
|
||
If the user-defined conversion is specified
|
||
by a constructor ([[class.conv.ctor]](class.conv.ctor "11.4.8.2 Conversion by constructor")), the initial standard
|
||
conversion sequence converts the source type to the type of the
|
||
first parameter of that constructor[.](#1.sentence-2)
|
||
|
||
If the user-defined
|
||
conversion is specified by a [conversion function](class.conv.fct "11.4.8.3 Conversion functions [class.conv.fct]"), the
|
||
initial standard conversion sequence
|
||
converts the source type to the type of the
|
||
object parameter of that conversion function[.](#1.sentence-3)
|
||
|
||
[2](#2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/overloading.tex#L2354)
|
||
|
||
The second standard conversion sequence converts the result of
|
||
the user-defined conversion to the target type for the sequence;
|
||
any reference binding is included in the second standard
|
||
conversion sequence[.](#2.sentence-1)
|
||
|
||
Since an implicit conversion sequence is an initialization, the
|
||
special rules for initialization by user-defined conversion apply
|
||
when selecting the best user-defined conversion for a
|
||
user-defined conversion sequence (see [[over.match.best]](over.match.best "12.2.4 Best viable function") and [[over.best.ics]](over.best.ics "12.2.4.2 Implicit conversion sequences"))[.](#2.sentence-2)
|
||
|
||
[3](#3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/overloading.tex#L2364)
|
||
|
||
If the user-defined conversion is specified by a
|
||
specialization of a conversion function template,
|
||
the second standard conversion sequence shall have Exact Match rank[.](#3.sentence-1)
|
||
|
||
[4](#4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/overloading.tex#L2369)
|
||
|
||
A conversion of an expression of class type
|
||
to the same class type is given Exact Match rank, and
|
||
a conversion of an expression of class type
|
||
to a base class of that type is given Conversion rank,
|
||
in spite of the
|
||
fact that a constructor (i.e., a user-defined conversion
|
||
function) is called for those cases[.](#4.sentence-1)
|